Validation Rule to not accept blank fields

dbrasel

Board Regular
Joined
Feb 25, 2005
Messages
88
Hi, hope someone can help with my validation list!

Field = Observation Kind: Formal or Informal (combo box)

Validation Rule:=[ObservationKind]=[ObservationKind] Is Not Null
Validation Text: Observation Kind Required

What is happening is that when I tab through the form, it skips the Observation Kind field altogether. I can go back and enter my choice, delete it, tab to the next field, and then I get the text message. What I want it to do is show the text if you tab through the Observation Kind field without choosing either formal or informal, and you can't move forward in the form until missing information is provided.

I'm working on Access 2000 database. Any suggestions will be greatly appreciated!

Deb
 
hi Roger,

this is what I have:

Private Sub ObservationKind_LostFocus()
If IsNull(Me.ObservationKind.Value) = True Then
MsgBox "You must choose either Informal or Formal.", vbCritical, "Error"
Me.ObservationKind.SetFocus True
Exit Sub
End If

End Sub

it stops at the SetFocus with this error message: Wrong number of arguments or invalid property assignment.

I think we're getting closer! thank you again for your help!

Deb
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Roger,

thank you, thank you, thank you! it works, exactly how I want - I'm doing the happy dance in the office. thank you so much!

I'm curious about one thing - did this require a macro because it was a combo box? I could not get it to work when I tried using the validation rule.

Deb
 
Upvote 0
I don't use the wizard to create validation rules, so I am not really sure. I went back and tried to duplicate what you wanted using the wizard but couldn't get it to work. I would venture it is possible and I/we were just missing a small piece or something. Luckily there are typically many ways to get something done if one way is not working.

Thanks,
Roger
 
Upvote 0
On the lost focus event of your combo box put in:

Code:
if isnull(me.cmbYourName.value) = true then

     msgbox "You must choose Informal or Formal.", vbcritical, "Error"

     me.cmbYourName.setfocus True

     Exit Sub

end if

HTH
Roger
Hi Roger,

Thanks for the code. It works nicely for me. However, I am facing another problem - after clicking OK on the message box, the cursor did not go back to the control (which is a textbox) to re-enter the data but jumps to the next control. Could you please help?
 
Upvote 0

Forum statistics

Threads
1,222,567
Messages
6,166,835
Members
452,077
Latest member
hufflefry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top