Making a control a required field

drschlong

Registered User.
Local time
Today, 22:56
Joined
Jun 12, 2002
Messages
33
Hello all,

This is my first post on these forums so please be gentle with me.

I have a combo box (which for these purposes is called "CMU")which displays "Yes" and "No", now if the user selects "Yes" then a text box (which I will call "MU Comments") must be filled in, if the user selects "No" then the same text box can either be filled in or left blank.

Does anybody know how I would go about the above. The two controls are on the same form so this should make things easier (I think).

Thanks in advance.

Steven.
 
If the combo source is simply Yes;No and has only one column then use this code either in the textbox LostFocus or AfterUpdate and on the Forms AfterUpdate.

If Me.NameOfCombo = "Yes" AND IsNull(Me.NameOfTextbox) = True Then
MsgBox "You must fill in MU comments before proceeding", ,"Fill In MU Comments"
Me.NameOfTextBox.SetFocus
End If

HTH
 
Fizzio,

That worked great, thanks alot for that.

As I am fairly new at using the code side of things in access what does the "Me" bit in for example "Me.NameOfCombo" mean or do.

Sorry if that sounds a bit of a thick question, but like I said I'm fairly (very) new at the code side of things.

Thanks,

Steven.
 
Me simply refers to the parent object ie in the example I gave, 'Me' refers to the form but it can be equally applied to a report also. I think it is called Relative Referencing rather than Explicit Referencing

Me.NameOfCombo (Relative)= Forms!NameOfForm!NameOfCombo (Explicit)

You would generally use 'Me' if you were referring to a control etc that resides on that form / report in the form / reports module.

You would use Forms!... in queries, in referencing controls not contained on that form etc.

HTH
 
Cheers Pat - Thanks for the correction (Glad you still keep a check on us amateurs :))
 

Users who are viewing this thread

Back
Top Bottom