prompt if "Other" is selected

J

JohnLute

If "Other" is selected in [Primary] then [OtherPrimary] requires an entry.

How can I do this?

Thanks!
 
A

Al Campagna

John,
That's very little info to go on...
Whatever object sets the value to "Other"... use the AfterUpdate event of that object
to generate a message.
In this example I'll use a textcontrol called Primary. (could be a combo or list,
etc...)

Private Sub Primary_AfterUpdate()
If Primary = "Other" Then
Beep
MsgBox "Some Message about the Requirement"
Docmd.GoToControl "OtherPrimary"
End If
End Sub

You might also want to make sure that the user doesn't leave OtherPrimary without an
entry.
Private Sub OtherPrimary_Exit(Cancel as Integer)
If Primary = "Other" And IsNull(OtherPrimary) Then
Beep
MsgBox "Entry Required!"
Cancel = True
End If
End Sub

These are just the basic concepts... you may want to plug up any other holes a user can
use to escape the entry, and do further validation of the OtherPrimary, but this should do
the trick.

--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
B

BruceS

John,
In the AfterUpdate event of [Primary] , try

If Me.Primary = "Other" then
Me.OtherPrimary.ValidationRule = ">''" 'If it is a string.
Me.OtherPrimary.ValidationText = "Entry is required for 'Other Primary'."
Else
Me.OtherPrimary.ValidationRule = ""
Me.OtherPrimary.ValidationText = ""
End If

Bruce
 
J

JohnLute

Thanks, Al!

That works perfectly. Thanks a bunch!

--
www.Marzetti.com


Al Campagna said:
John,
That's very little info to go on...
Whatever object sets the value to "Other"... use the AfterUpdate event of that object
to generate a message.
In this example I'll use a textcontrol called Primary. (could be a combo or list,
etc...)

Private Sub Primary_AfterUpdate()
If Primary = "Other" Then
Beep
MsgBox "Some Message about the Requirement"
Docmd.GoToControl "OtherPrimary"
End If
End Sub

You might also want to make sure that the user doesn't leave OtherPrimary without an
entry.
Private Sub OtherPrimary_Exit(Cancel as Integer)
If Primary = "Other" And IsNull(OtherPrimary) Then
Beep
MsgBox "Entry Required!"
Cancel = True
End If
End Sub

These are just the basic concepts... you may want to plug up any other holes a user can
use to escape the entry, and do further validation of the OtherPrimary, but this should do
the trick.

--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."


JohnLute said:
If "Other" is selected in [Primary] then [OtherPrimary] requires an entry.

How can I do this?

Thanks!
 
Top