How to make field not able to input data ONLY IF...

duckster

Registered User.
Local time
Today, 10:34
Joined
Jul 17, 2004
Messages
78
I have an area on my form for basic marketing information, with the following 4 fields:

HowHeardAboutUs: (drop-down box can choose either online, friend, flyer)

OnlineMethod:

FriendName:

FlyerLocation:


Now, I want all the irrelevant fields to become inactive and state "n/a" depending on which item is chosen for HowHeardAboutUs. For example, if HowHeardAboutUs field states "Online", then I want the FriendName and FlyerLocation fields to become inactive, and state 'n/a'.

I think I need to input an expression similar to this in the OnlineMethod control source: =IIf([HowHeardAboutUs] <> = "Online", "n/a", ****** )

The above expressions works, b/c the OnlineMethod field will default to "n/a" if "Online" is not chosen; however, I don't know what to put in the ******* area. I want the **** area to state "please enter website", and allow users to erase the "please enter site" and enter the website where the clients' heard about us.

Please help ! Thanks!
 
I don't think you want to us a conditional If there... U want to use some VBA code..

in the after_update event for the combo box put this:

If Me.OnlineMethod.Column(0) = "Online" then
Me.FriendName.Enabled = False
Me.FlyerLocation.Enabled = False
Else
Me.FriendName.Enabled = True
Me.FlyerLocation.Enabled = True
End If


hope this helps
 
Thanks...but not working. I put this code into the After_Update in the properties of the HowHeardAboutUs field:

If Me.HowHeardAboutUs.Column(0) = "Online" then
Me.FriendName.Enabled = False
Me.FlyerLocation.Enabled = False
Else
Me.FriendName.Enabled = True
Me.FlyerLocation.Enabled = True
End If


When I go to the form, and I choose "Online" in the HowHeardAboutUs field, I get a message: cannot find the macro 'If Me.'
 
that's because you put it in as a macro.

When you click the ellipse(...) choose event procedure not macro then enter that code into the VBA window.
 
Thanks a lot Treason, that worked.

When "Online" is selected, the other fields get blanked out except the "OnlineMethod" field, which is great.

I've replicated the code for the other fields, ie. if "Flyer" is selected, the fields "OnlineMethod" and "ReferralName" get blanked out and "FlyerLocation" is the only field active.

I'm not sure where this additional code would go though. I entered it into the end, right after "End If", but it didn't work...I also tried putting it in a few other places but it wouldn't work either. Do you know where I would stick the additional code to complete the code for the marketing questions?

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom