By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
461,942 Members | 756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 461,942 IT Pros & Developers. It's quick & easy.

Cannot get form to show field based on value of another field

P: 2
I have created a inventory tracking database and I want to show/hide certain fields based on the device category. The deviceCategory field is a lookup field to a table that lists all the different type of devices to include PC, Printer, Network....

I want it so that when you select a certain category device you get the fields related to the device. For example if you get PC I want to show the fields for Model, Service Tag, RAM, ....

For testing Im only working with showing the model field. I currently have the model field visible set to "No" and then in the deviceCategory I set an afterUpdate event to

Expand|Select|Wrap|Line Numbers
  1. Private Sub test_AfterUpdate()
  2. If deviceCategory = "test" Then
  3. deviceModel.Visable = True
  4. End Sub
According to it should work. What am I doing wrong? Thanks!
Mar 24 '10 #1
Share this Question
Share on Google+
3 Replies

Expert 2.5K+
P: 3,532
You have your code in the AfterUpdate event of a Control named test and you have no End If. It needs to be in the deviceCategory_AfterUpdate event, and really should read:
Expand|Select|Wrap|Line Numbers
  1. Private Sub deviceCategory_AfterUpdate()
  2.  If Me.deviceCategory = "test" Then
  3.    deviceModel.Visable = True
  4.  End If
  5. End Sub

Welcome to Bytes!

Linq ;0)>
Mar 24 '10 #2

P: 2
thank you for the reply. My original post had the wrong info from my test db. I corrected it as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Category_AfterUpdate()
  2. If Me.Category = "Laptop" Then
  3.  Model.Visible = True
  4. End If
  5. End Sub
OK, it is working when I have the Category set up as a text field. However, category is a drop down list from which to select the value. How do I get it to update this way? When I have a drop down list it does not work w/ afterUpdate?

Also, it appears that when Laptop is listed in Category it now shows the Model field over every record. I want it to only show on the records for which category is listed as laptop, still hide on all other records.
Mar 29 '10 #3

Expert Mod 15k+
P: 31,770
See Why Values in Unbound Form Controls do not Persist for why that won't work. You would need to look at creating the condition in the underlying record source. Even then I doubt you could hide the control exactly.
Mar 29 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.