Hi Every Body
At first let me explain the situation a bit.
I have a form. Upon Opening the Form, In order to make my users to select an option in my comboBox (Indexed value is 0), I have the following Codes:
Private Sub Combo144_LostFocus()
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
If IsNull(Me!Combo144) Then
strMsg = "You must pick a Customer"
strTitle = "Bill To Customer Required"
intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle
Me.CompanyName.SetFocus
Me.Combo144.SetFocus
Else
Me.InvoiceNo.SetFocus
End If
End Sub
Which sort of works, Otherwise If the user does not pick a value from my comboBox He /She cannot go any Further and the MsgBox Pups up.
But here is the problem; the user should be able to close the form, even if they have not
Pick any value from my comboBox Therefore I came up with the following codes Which They do not work and my Msgbox Pups up 3 times:
Private Sub Form_Close()
If IsNull(Me!Combo144) Then
Me!Combo144.Enabled = False
DoCmd.RunCommand acCmdUndo
DoCmd.Close acForm, "Sales"
End If
End Sub
I tried the above in my Onload Event No Success, also I used Me.Combo144 rather than Me!Combo144 But still no success.
Here is the code I Have on Opening my form if it helps any:
Private Sub Form_Open(Cancel As Integer)
Forms!sales.UniqueTable = "Tablesales"
DoCmd.GoToRecord , , acNewRec
Me.Combo144.SetFocus
End Sub
Could you tell me, What are wrong with my coding?
Basically I think the problem should be in my Close Event coding.
Best regads
sanan
At first let me explain the situation a bit.
I have a form. Upon Opening the Form, In order to make my users to select an option in my comboBox (Indexed value is 0), I have the following Codes:
Private Sub Combo144_LostFocus()
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
If IsNull(Me!Combo144) Then
strMsg = "You must pick a Customer"
strTitle = "Bill To Customer Required"
intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle
Me.CompanyName.SetFocus
Me.Combo144.SetFocus
Else
Me.InvoiceNo.SetFocus
End If
End Sub
Which sort of works, Otherwise If the user does not pick a value from my comboBox He /She cannot go any Further and the MsgBox Pups up.
But here is the problem; the user should be able to close the form, even if they have not
Pick any value from my comboBox Therefore I came up with the following codes Which They do not work and my Msgbox Pups up 3 times:
Private Sub Form_Close()
If IsNull(Me!Combo144) Then
Me!Combo144.Enabled = False
DoCmd.RunCommand acCmdUndo
DoCmd.Close acForm, "Sales"
End If
End Sub
I tried the above in my Onload Event No Success, also I used Me.Combo144 rather than Me!Combo144 But still no success.
Here is the code I Have on Opening my form if it helps any:
Private Sub Form_Open(Cancel As Integer)
Forms!sales.UniqueTable = "Tablesales"
DoCmd.GoToRecord , , acNewRec
Me.Combo144.SetFocus
End Sub
Could you tell me, What are wrong with my coding?
Basically I think the problem should be in my Close Event coding.
Best regads
sanan