Hi all!!!! I have a form that I update a comment field using the Lost Focus event. The problem is the the Lost Focus event causes the program to lose the event that caused the Lost Focus event in the first place. Say the user changes the comments and then hits Close. The comments get updated properly but the form does not close, the user has to click Close a 2nd time to get the form to close.
here is the code I have in the Lost Focus event:
Private Sub txtRC2New_LostFocus()
Dim strcmbRouteValue As String
Dim strCurrentRecord As String
Me.Dirty = False
strcmbRouteValue = Me.cmbRoute.Value
strCurrentRecord = Forms!frmBaseRouteAssignment![subfrmRouteEfficiencyDetail].Form!txtPartNumber.Value
If Me.txtRC2 <> Me.txtRC2New Then
'update tblRouteInfo
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblRouteInfo SET tblRouteInfo.RouteComment2 = [Forms]![frmBaseRouteAssignment]![txtRC2New]" _
& " WHERE (((tblRouteInfo.PlantCode)= " & "'" & Me.txtPlantCode.Value & "'" & ")" _
& " AND ((tblRouteInfo.Route)= " & "'" & Me.cmbRoute.Value & "'" & ")" _
& " AND ((tblRouteInfo.ModelYear)= " & "'" & Me.txtModelYear.Value & "'" & "));"
DoCmd.SetWarnings True
End If
Me.Requery
Me.cmbRoute.Value = strcmbRouteValue
Me.Recordset.FindFirst "Route = " & "'" & strcmbRouteValue & "'" & ""
End Sub
Must be late in the day because I am drawing a complete blank on this. How do I capture the button or field or whatever is being clicked on the form and then execute after the Lost Focus event in the Comment field?
Joel
here is the code I have in the Lost Focus event:
Private Sub txtRC2New_LostFocus()
Dim strcmbRouteValue As String
Dim strCurrentRecord As String
Me.Dirty = False
strcmbRouteValue = Me.cmbRoute.Value
strCurrentRecord = Forms!frmBaseRouteAssignment![subfrmRouteEfficiencyDetail].Form!txtPartNumber.Value
If Me.txtRC2 <> Me.txtRC2New Then
'update tblRouteInfo
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblRouteInfo SET tblRouteInfo.RouteComment2 = [Forms]![frmBaseRouteAssignment]![txtRC2New]" _
& " WHERE (((tblRouteInfo.PlantCode)= " & "'" & Me.txtPlantCode.Value & "'" & ")" _
& " AND ((tblRouteInfo.Route)= " & "'" & Me.cmbRoute.Value & "'" & ")" _
& " AND ((tblRouteInfo.ModelYear)= " & "'" & Me.txtModelYear.Value & "'" & "));"
DoCmd.SetWarnings True
End If
Me.Requery
Me.cmbRoute.Value = strcmbRouteValue
Me.Recordset.FindFirst "Route = " & "'" & strcmbRouteValue & "'" & ""
End Sub
Must be late in the day because I am drawing a complete blank on this. How do I capture the button or field or whatever is being clicked on the form and then execute after the Lost Focus event in the Comment field?
Joel