Hi hymn
I am just about to call it quit.
I do not know what are wrongs with these codes, They sometimes work and others in Identical situations or where they supposed to work, They just do not work.
About your comments, There are no other codes basically let’s say the we have the cmbo144 and a textbox called InvoiceNo.
I have the identical codes in both just some adjustments for their names.
Here are all the codes
Private Sub Combo144_LostFocus()
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
If Me.Combo144.DefaultValue Then
strMsg = "You must pick a value from the Bill To list."
strTitle = "Bill To Customer Required"
intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle
Me.City.SetFocus
Me.Combo144.SetFocus
Else
Me.InvoiceNo.SetFocus
End If
End Sub
Codes for InvoiceNo
Private Sub InvoiceNo_LostFocus()
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
If IsNull(Me.InvoiceNo) Or Me.InvoiceNo = "" Then
strMsg = "You must Enter an Invoice No. A Date Or Check No.."
strTitle = "Invoice Number Required"
intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle
Me.ReffrenceID.SetFocus
Me.InvoiceNo.SetFocus
End If
End Sub
My Onload and close Events
Private Sub Form_Open(Cancel As Integer)
Form.UniqueTable = "Tablesales"
DoCmd.GoToRecord , , acNewRec
Me.Combo144.SetFocus
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim strMsg As String, strTitle As String
strMsg = "Entries Are Out Of Balance."
strTitle = "Inventory101"
intStyle = vbOKOnly
If Sd.Value - SC.Value <> 0 Then
MsgBox strMsg, intStyle, strTitle
DoCmd.CancelEvent
End If
End Su
But what is Puzzling is why this code does not work
Private Sub Form_Close()
Me.Combo144.Enabled = False
End Sub
The above does not work for the onload too.
By the way I tried your suggestion, and the following did not work too.
Private Sub Form_Close()
DoCmd.RunCommand acCmdUndo
DoCmd.Close
End Sub
Also in Onload event did not work.
Another strange thing
I tried to introduce a Default value for my combo144 of the value (“”)
Therefore my combo144 has always has the value “” and at the time of closing is no longer Null and then I changed my Combo144 onLost event a little bit which goes as follow:
Private Sub Combo144_LostFocus()
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
If Me.Combo144.DefaultValue Then
Or If Me!combo144 = “” Then
Or If Me.combo144.value =”” then
strMsg = "You must pick a value from the Bill To list."
strTitle = "Bill To Customer Required"
intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle
Me.City.SetFocus
Me.Combo144.SetFocus
Else
Me.InvoiceNo.SetFocus
End If
End Sub
But Nothing works, Now isn’t this really strange, Since The above is Identical codes that used to work before.
Best regards,
Sanan