sphere_monk
Registered User.
- Local time
- Today, 10:03
- Joined
- Nov 18, 2002
- Messages
- 62
I am using the following code to find a workorder record when the workorder ID is chosen in the cboWOID combo box. It finds workorders fine until I enter a new workorder. Then it can't find the new workorder. Can anyone pick out what I'm missing? Thanks!
Private Sub cboWOID_AfterUpdate()
MsgBox ("Running cboWOID_AfterUpdate")
Dim strCriteria As String
Dim WOtoFind As String
Dim rst As New ADODB.Recordset
Set rst = Me.Recordset
rst.MoveFirst
WOtoFind = Me.cboWOID
strCriteria = "WOID = " & Me!cboWOID
rst.Find strCriteria
If rst.EOF Then GoTo SetDefaults
MsgBox ("Found Matching Record")
Call ChangeColor(cboWOID)
Call DisableFields
GoTo Exit_cboWOID_AfterUpdate
SetDefaults:
MsgBox ("Did not find matching record")
MsgBox ("Moving to New Record")
rst.AddNew
Call EnableFields
Call NewWODefaults(cboWOID)
Call ChangeColor(cboWOID)
Me!txtDate.SetFocus
Exit_cboWOID_AfterUpdate:
Exit Sub
End Sub
Private Sub cboWOID_AfterUpdate()
MsgBox ("Running cboWOID_AfterUpdate")
Dim strCriteria As String
Dim WOtoFind As String
Dim rst As New ADODB.Recordset
Set rst = Me.Recordset
rst.MoveFirst
WOtoFind = Me.cboWOID
strCriteria = "WOID = " & Me!cboWOID
rst.Find strCriteria
If rst.EOF Then GoTo SetDefaults
MsgBox ("Found Matching Record")
Call ChangeColor(cboWOID)
Call DisableFields
GoTo Exit_cboWOID_AfterUpdate
SetDefaults:
MsgBox ("Did not find matching record")
MsgBox ("Moving to New Record")
rst.AddNew
Call EnableFields
Call NewWODefaults(cboWOID)
Call ChangeColor(cboWOID)
Me!txtDate.SetFocus
Exit_cboWOID_AfterUpdate:
Exit Sub
End Sub