Form Navigation and Setfocus Woes

stevenblanc

Registered User.
Local time
Yesterday, 19:16
Joined
Jun 27, 2011
Messages
103
Hi folks,

So I decided today that I would attempt to minimize the number of forms that I use by using the same form for entry and review. Fairly straight forward, just turn allow additions on when the user uses my custom nav buttons or enters a customerID that already exists.

However, I would also like to disable the customerID field when I allow additions so that the user cannot modify customerIDs once the customer record has been created. I thought that would be a very simple process: setfocus to another control and disable the customerID textbox.

Well, I cannot seem to find a way to do this without getting error 2108:

"You must save the field before you execute the GotoControl action, the gotocontrol method, or the setfocus method."

I originally had the code to setfocus and disable in the controls before update event. But that fires before the update so I cant disable it.

When I attempt to setfocus and disable in the control afterupdate or form afterupdate they dont fire at all.

I get the same error if I try to setfocus and disable in the form current (as this fires during the before update event.

The before update code is as follows:

Code:
Private Sub txtCustomerGPID_BeforeUpdate(Cancel As Integer)
    Dim strCustomerGPID As String
    Dim strLinkCriteria As String

    If txtCustomerGPID.Value <> "" Then
        strCustomerGPID = Me.txtCustomerGPID.Value
        strLinkCriteria = "[CustomerGPID]=" & "'" & strCustomerGPID & "'"
    
        'Check Customers table for duplicate Customer GP ID
        If DCount("CustomerGPID", "tblCustomers", strLinkCriteria) > 0 Then
        
            'Undo duplicate entry and Go to original customer record
            Me.Undo
        
        If Me.DataEntry = True Then
            Me.DataEntry = False
            Me.AllowAdditions = False
        End If
            
        Me.Recordset.FindFirst strLinkCriteria
        If Me.Recordset.NoMatch Then MsgBox "The selected record no longer exists."
        
        
        
        End If
    End If

End Sub

I'd appreciate anyone ideas on where to make my changes afterwards.
 
Well I moved everything to afterupdate and it works pretty well. Don't know why that took so long to click. Thanks anyway folks.
 

Users who are viewing this thread

Back
Top Bottom