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

Proofread code - Make field visible based on value in another field

P: 7
Hi,

I'm trying to get a certain field to appear only when a value from another combobox field is selected. Specifically, when "Sample Rejected" is selected in the field "PcrLabResults," I would like the "ReasonsRejected" field to appear. I've set the visibility option for "ReasonsRejected" to "No" already. I still can't get it to work. Do I need to do anything after entering this code (ie save, click "run," etc), or will it update in the form automatically? Here's my code - please let me know what I'm doing wrong. Many thanks in advance.

Expand|Select|Wrap|Line Numbers
  1. Private Sub PcrLabResults_AfterUpdate()
  2.   If Me.PcrLabResults = "Sample rejected" Then
  3.     RejectionReasons.Visible = True
  4.   End If
  5. End Sub

PS - I've looked at these two threads, and still can't seem to get it right:

http://bytes.com/topic/access/answer...-another-field

http://bytes.com/topic/access/answer...her-form-field
Apr 29 '10 #1
Share this Question
Share on Google+
4 Replies


missinglinq
Expert 2.5K+
P: 3,532
Well, first off, you give the control name as ReasonsRejected in your post, but use the name RejectionReasons in your code. Which is it?

Linq ;0)>
Apr 29 '10 #2

P: 7
Sorry about that - it's "RejectionReasons." Still won't work...
Apr 30 '10 #3

NeoPa
Expert Mod 15k+
P: 31,186
I would change the code slightly so that it both sets and resets the visibility status of the other control :
Expand|Select|Wrap|Line Numbers
  1. Private Sub PcrLabResults_AfterUpdate()
  2.   RejectionReasons.Visible = (Me.PcrLabResults = "Sample rejected")
  3. End Sub
That said, I see no reason why your code wouldn't work as it was. Can you try this and let us know what you get. The clearer your response, the better able we'll be to help.
Apr 30 '10 #4

missinglinq
Expert 2.5K+
P: 3,532
Also
  1. What version of Access are you running?
  2. What kind of form are you using? Single, Continuous or Datasheet?
  3. What exactly do you mean by "I still can't get it to work" WHat happens?
Linq ;0)>
Apr 30 '10 #5

Post your reply

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