Delayed Update for cmdButton on Split Form When User Selects A Different Record

LWoods

Registered User.
Local time
Today, 12:11
Joined
Feb 6, 2012
Messages
19
Hi All:

I have split form that has the record details on the top, with a list of all records on the bottom. In the top, there is also a few cmd buttons, one of which needs to become enabled or disabled depending on the record that is selected.

Currently, I've got the following code in the OnCurrent event which determines if the selected record variables are "N-" documents...

Code:
Private Sub Form_Current()
 
Dim DocNum As String
Dim ProgNum As String
 
DocNum = Nz(Me.txtDocNumber.Value, "")
ProgNum = Nz(Me.txtProgram.Value, "")
 
If Mid(DocNum, 1, 2) = "N-" Or Mid(ProgNum, 1, 2) = "N-" Then
    Me.cmdTeamList.Enabled = True
Else
    Me.cmdTeamList.Enabled = False
End If
 
End Sub

For some reason, the code is working -- but delayed... If I select a record that meets the criteria, the button stays disabled, but then is enabled on the next record selection regardless of whether or not it meets the criteria. Then the next selection will enable/disable the button depending on if the criteria was met in the last record that was selected.

Does anyone know why this is happening? I thought that the OnCurrent event was supposed to capture the current record and not the previous one.

I've tried using the Before Update and After Update events too, with no luck...

Any help is greatly appreciated!

Many thanks,
-L
 

Users who are viewing this thread

Back
Top Bottom