Adding code to display labels when records change

Brad4566

Brad
Local time
Today, 18:27
Joined
Nov 19, 2004
Messages
8
I have an inventory database that I made for a company. It is a complex database, but I have most of it figured out. One problem I ran into is the fact that I am trying to make a certain form user friendly by filling in most of the labels and text fields on the form load. The only problem is that the code only works at the form load and not when you change records. Where could you put code at to fill in the labels again when the user changes records. any help would be appreciated. If any clarification is needed let me know.
 
Try the Current event
 
I tried that one but my database got locked up. And a question to add is how do you check to see if a field has nothing in it. An example would be: I have 80 text fields that is linked to a table. I have labels that say Pass all the time. What I am trying to do is find the last value entered in the text fields so I can display the correct ammount of labels. Say for instance there are 22 text fields that have values entered in them. How can I get 22 labels to show up using code.
 
Last edited:
You can hide the text box if the text box is Null. The related label will also be hidden if the text box is not visible. Try something like this in your OnCurrent event...
Code:
Private Sub Form_Current()
On Error GoTo Form_Current_Err

    If IsNull(tbMiddleName) Or tbMiddleName = "" Then
        tbMiddleName.Visible = False
    Else
        tbMiddleName.Visible = True
    End If
    
    If IsNull(tbDOB) Or tbDOB = "" Then
        tbDOB.Visible = False
    Else
        tbDOB.Visible = True
    End If

Form_Current_Exit:
    Exit Sub

Form_Current_Err:
    MsgBox Err.Number & " - " & Err.Description
    Resume Form_Current_Exit

End Sub
 

Users who are viewing this thread

Back
Top Bottom