I am setting certain fields as being required. I would like for the cursor to automatically go to the field that is required, but not filled in. This is what I have so far.
Private Sub txtFirstName_BeforeUpdate(Cancel As Integer)
If IsNull(txtFirstName) Then
'Checks to see if Information has been input into field.
MsgBox txtFirstName.Name & " is required!"
'This field is a required field.
txtFirstName.SetFocus
Exit Sub
End If
End Sub
Private Sub txtLastName_BeforeUpdate(Cancel As Integer)
'Checks to see if Information has been input into field.
'This field is a required field.
If IsNull(txtLastName) Then
MsgBox txtLastName.Name & " is required!"
txtLastName.SetFocus
Exit Sub
End If
End Sub
Private Sub cboTitle_BeforeUpdate(Cancel As Integer)
'Checks to see if Information has been input into field.
'This field is a required field.
If Nz(cboTitle) Then
MsgBox cboTitle.Name & " is required!"
cboTitle.SetFocus
Exit Sub
End If
End Sub
Private Sub txtReportsTo_BeforeUpdate(Cancel As Integer)
'Checks to see if Information has been input into field.
'This field is a required field.
If IsNull(txtReportsTo) Then
MsgBox txtReportsTo.Name & " is required!"
txtReportsTo.SetFocus
Exit Sub
End If
End Sub
It does not set the focus back to the txtFirstName field.
Any idea what I am doing wrong here? I have 4 different fields on this form. My fields go in this order: txtFirstName, txtLastName, cboTitle, txtReportsTo.
According to what I have read, and Lonnie Johnson this should work.
Thanks,
Don Thank you for your help and time. It is greatly appreciated!!!
Thanks,
Don
please CC both addresses
f613493c@mailfxhome.fedex.com
mrfilez@midsouth.rr.com
Private Sub txtFirstName_BeforeUpdate(Cancel As Integer)
If IsNull(txtFirstName) Then
'Checks to see if Information has been input into field.
MsgBox txtFirstName.Name & " is required!"
'This field is a required field.
txtFirstName.SetFocus
Exit Sub
End If
End Sub
Private Sub txtLastName_BeforeUpdate(Cancel As Integer)
'Checks to see if Information has been input into field.
'This field is a required field.
If IsNull(txtLastName) Then
MsgBox txtLastName.Name & " is required!"
txtLastName.SetFocus
Exit Sub
End If
End Sub
Private Sub cboTitle_BeforeUpdate(Cancel As Integer)
'Checks to see if Information has been input into field.
'This field is a required field.
If Nz(cboTitle) Then
MsgBox cboTitle.Name & " is required!"
cboTitle.SetFocus
Exit Sub
End If
End Sub
Private Sub txtReportsTo_BeforeUpdate(Cancel As Integer)
'Checks to see if Information has been input into field.
'This field is a required field.
If IsNull(txtReportsTo) Then
MsgBox txtReportsTo.Name & " is required!"
txtReportsTo.SetFocus
Exit Sub
End If
End Sub
It does not set the focus back to the txtFirstName field.
Any idea what I am doing wrong here? I have 4 different fields on this form. My fields go in this order: txtFirstName, txtLastName, cboTitle, txtReportsTo.
According to what I have read, and Lonnie Johnson this should work.
Thanks,
Don Thank you for your help and time. It is greatly appreciated!!!
Thanks,
Don
please CC both addresses
f613493c@mailfxhome.fedex.com
mrfilez@midsouth.rr.com