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

How do I hide a form field and only show it based on the value of another form field?

P: 2
Hello , I am using MS Access 2000. I have a Table called Transactions, I have created a form for this table, one of the fields on the form is a combo box with the row source type as value list. In this combo box field that I call "Transaction type" the user must select a value from the drop down list.

What I want to do is based on the selection of the "Transaction type" field, if the user should select a transaction type of ADHOC or EMERGENCY or CCB CR. I would like another field I have created as a text box called "CHANGE REQUEST #" to show on the form. If they select an of the other transaction other then the ADHOC or EMERGENCY or CCB CR then I do now want the "CHANGE REQUEST #" text box field to show on the form. ??

Is this possible to do ?
Please advise..
Thank you.
Nov 14 '08 #1
Share this Question
Share on Google+
3 Replies


P: 90
Should be.
Set the 'visible' property of the CHANGE REQUEST # control to No.
Then on the 'OnChange' value of the 'Transaction Type' combo box try the following:

Expand|Select|Wrap|Line Numbers
  1. If Me.Transaction_type = "ADHOC" Or _
  2.     Me.Transaction_type = "EMERGENCY" Or _
  3.     Me.Transaction_type = "CCB CR" Then
  4. Me.CHANGE_REQUEST_#.Visible = True
  5. Else
  6. Me.CHANGE_REQUEST_#.Visible = False
  7. End If
You might need to edit the control names slightly, I copied what you posted and added _ where there was a space (cos I think that's what Access does).

Lemme know if it works. x
Nov 14 '08 #2

P: 2
Thank you so much for this response so quickly. I assume I am going to choose code builder and when I get the MS Visuual Basic box I copy and past what you have below, however can I ask the name after the Me. is that the text box Name or the Control Source name of the text box? I'm asking because it's not liking what I have in the Me.CHANGE_REQUEST_# part of the below statement.

I'm getting an error saying Compile Error : Method or Data member not found.
and it will highlight the CHANGE_REQUEST_# ??? I'm guessing I'm not using the correct name for that text box?? I'm very new at all this and I really appreciate your help.
Steve

If Me.Transaction_type = "ADHOC" Or _
Me.Transaction_type = "EMERGENCY" Or _
Me.Transaction_type = "CCB CR" Then
Me.CHANGE_REQUEST_#.Visible = True
Else
Me.CHANGE_REQUEST_#.Visible = False
End If
Nov 14 '08 #3

missinglinq
Expert 2.5K+
P: 3,532
Before you go any further here, I'd change the name of

CHANGE_REQUEST_#

to something like

CHANGE_REQUEST_No

or

CHANGE_REQUEST_Number

The pound sign (#) is used as a delimiter in VBA to let Access know that what lies between two of them represents a date. It may be what's causing the problem with

Expand|Select|Wrap|Line Numbers
  1. If Me.Transaction_type = "ADHOC" Or _
  2. Me.Transaction_type = "EMERGENCY" Or _
  3. Me.Transaction_type = "CCB CR" Then
  4. Me.CHANGE_REQUEST_#.Visible = True
  5. Else
  6. Me.CHANGE_REQUEST_#.Visible = False
  7. End If     
Access may very well be considering

#.Visible = TrueElseMe.CHANGE_REQUEST_#

to be a date, and is unable to interpret it, hence the error. It's sure to cause you trouble, sooner or later.

Welcome to Bytes!

Linq ;0)>
Nov 15 '08 #4

Post your reply

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