I am attempting to create a button where the Caption of the button changes depending on which record is currently active on a form. I was able to find a post on a stackoverflow forum that has me very close here. However It works as expected EXCEPT when I select the first record in the database. (I am making the selection using a drop down/combo box)
I have other controls that are reliant on the same method that do pull the appropriate field info, so it's not an issue with the drop down/combo box. If I select any other record in the database, the button caption is changed as expected, but when I select the first record in the database, the caption is not changed and I can't figure out why.
I am just learning to use VBA code so I'm wondering if I have missed something obvious here.
Also, the form used initially loads to a 'new record' and so everything is blank upon load, so a record is required to be selected by the user for any information to appear.
The code I have used is as follows:
It seems pretty simple code, and ultimately I am simply attempting to pull in an employee name from the database based upon the current/active record. Again, this works except when I select the record for the first employee in the database.
Thanks for your help.
A Fish
I have other controls that are reliant on the same method that do pull the appropriate field info, so it's not an issue with the drop down/combo box. If I select any other record in the database, the button caption is changed as expected, but when I select the first record in the database, the caption is not changed and I can't figure out why.
I am just learning to use VBA code so I'm wondering if I have missed something obvious here.
Also, the form used initially loads to a 'new record' and so everything is blank upon load, so a record is required to be selected by the user for any information to appear.
The code I have used is as follows:
Code:
Private Sub Form_Current()
If Nz(Me.EMP_NAME, "") <> "" Then
Me.Command172.Caption = "Info for " & Me.EMP_NAME
Else
Me.Command172.Caption = ""
End If
End Sub
It seems pretty simple code, and ultimately I am simply attempting to pull in an employee name from the database based upon the current/active record. Again, this works except when I select the record for the first employee in the database.
Thanks for your help.
A Fish