Form Requery / Refresh problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gilberto
    New Member
    • Aug 2007
    • 135

    Form Requery / Refresh problem

    Hello,

    I have a form with some buttons that take the user to reports, other forms, etc. On this form the user can see how many products are missing costing and pricing information, through some textboxes that i have designed with some code. The problem is that when the user opens another form, modifies products and comes back to the original form (which remains OPEN) the "status" of the missing products remain the same.

    In other words, i cant find the way to refresh/requery the form and textboxes so that it checks again if products are missing. Ive tried different events with no luck...the missing products only reflect changes if the form is CLOSED AND OPENED again.

    the current code is:
    Code:
    Private Sub Form_Load()
    
    Me.costingmissingtxt.Requery
    Me.pricingmissingtxt.Requery
    
    If Me.costingmissingtxt.Value >= 1 Then
    Me.missingtxt.Visible = True
    Me.missingtxt.ForeColor = 255:
    Me.costingmissingtxt.Visible = True
    Me.oktxt.Visible = False
    Me.costingmissingtxt.ForeColor = 255
    Me.missingtxt.Value = "MISSING:"
    Else
    Me.costingmissingtxt.Visible = False
    Me.missingtxt.Visible = False
    Me.oktxt.Visible = True
    Me.oktxt.ForeColor = 65280:
    Me.oktxt.FontBold = True
    Me.oktxt.Value = "OK"
    End If
    
    If Me.pricingmissingtxt.Value >= 1 Then
    Me.missing2txt.Visible = True
    Me.missing2txt.ForeColor = 255:
    Me.pricingmissingtxt.Visible = True
    Me.ok2txt.Visible = False
    Me.pricingmissingtxt.ForeColor = 255
    Me.missing2txt.Value = "MISSING:"
    Else
    Me.pricingmissingtxt.Visible = False
    Me.missing2txt.Visible = False
    Me.ok2txt.Visible = True
    Me.ok2txt.ForeColor = 65280:
    Me.ok2txt.FontBold = True
    Me.ok2txt.Value = "OK"
    End If
    Any ideas if the code is flawed or where to put it???
    Thanks,
    Gilberto
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    try>>> Me.Requery<<<<< on the Form_AfterUpdat e() event for the form (main form or actual subform (the source object, not the control) to which the selection is to be refreshed.

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Just out of curiosity, how do you let the users know which fields need data? I use Conditional Formatting to change the BackColor to Red.

      Linq ;0)>

      Comment

      • Gilberto
        New Member
        • Aug 2007
        • 135

        #4
        Thanks guys, i used the ACTIVE event for the form, modified the code and it WORKED hahah.

        Thanks for the replies. The code that worked is:
        Code:
        Private Sub Form_Activate()
        Me.Refresh
        Me.Requery
        Me.costingmissingtxt.Requery
        Me.pricingmissingtxt.Requery
        
        If Me.costingmissingtxt.Value = 0 Then
        Me.missingtxt.Visible = False
        Me.missingtxt.ForeColor = 255:
        Me.missingtxt.Value = "MISSING:"
        Me.costingmissingtxt.Visible = False
        Me.costingmissingtxt.ForeColor = 255
        Me.oktxt.Visible = True
        Me.oktxt.FontBold = True
        Else
        Me.costingmissingtxt.Visible = True
        Me.missingtxt.Visible = True
        Me.oktxt.Visible = False
        Me.oktxt.ForeColor = 65280:
        Me.oktxt.Value = "OK"
        End If
        
        If Me.pricingmissingtxt.Value = 0 Then
        Me.missing2txt.Visible = False
        Me.missing2txt.ForeColor = 255:
        Me.missing2txt.Value = "MISSING:"
        Me.pricingmissingtxt.Visible = False
        Me.pricingmissingtxt.ForeColor = 255
        Me.ok2txt.Visible = True
        Me.ok2txt.FontBold = True
        Else
        Me.pricingmissingtxt.Visible = True
        Me.missing2txt.Visible = True
        Me.ok2txt.Visible = False
        Me.ok2txt.ForeColor = 65280:
        Me.ok2txt.Value = "OK"
        End If
        
        End Sub

        Comment

        Working...