Hi everybody! I'm a total newbie at access, just opened it for the first time yesterday so bear with me. I tried a search for my answer and found similar topics but couldn't find the exact answer.
I'm using 2002 Access on XP. In a form, I created a combo box with four different choices. Depending on the selection made I would like a corresponding field to appear. My four selections in the combo box are "Realtor", "Driving", "Mailing", or "Other". If "Realtor" is selected I want a field to appear that asks for the realtor's name and another field that asks for the realtor's phone number. If "Driving" is selected, I want a field to ask for a date. Same for if "Mailing" is selected. If "Other" is selected, I'd like the field to appear where you can enter text to explain.
I have a feeling that the answer lies somewhere under "properties" for my combo box but there is so much in there and it's all over my head. Thanks for any help!
14 1848
in your properties set all of your fields to visible no then for your combo box on the after update even in properties again you'll need a good amount of code like this
If me.ComboName = "Realtor" Then
me.name of textbox.visible = True
else
if me.ComboName = "Whatever" Then
me.Whatever.Visible = True
End If
Hope thats what you were trying to do
Thanks for the suggestion!
I tried it but I couldn't change any of the fields to visible = no. I get an error message that reads "You can't hide a control that has the focus."
What does that mean?
Ferguson,
First of all, the code reads
If I were you, I would write nested "If, Then, Else" statements, like the ones already posted, for all four of your choices in the combo box. I would tie each one of those statements to reference the separate text boxes on your form and use the ".Visible = Condition" property in the nested statements to display the appropriate text box on the "AfterUpdate" event of the combo. This should work fine if your typing the code in the correct manner. I'm not sure why you received the error message that you did, but it would lead me to believe that any statement you've written in the module thus far does not contain the correct syntax (sequence of script). Maybe you could post it??
I tried it but I couldn't change any of the fields to visible = no. I get an error message that reads "You can't hide a control that has the focus."
Where were you trying to set the visibilty? The instructions said to set this in the properties box! The control couldn't have focus here! In Design View, select all of the textboxes you want to control the visibilty of. Goto Properties - Form and set the Visibility Property to No. Then try your code in the combobox's afterupdate event.
You'll also have to save one of these 4 designations to each record, and use that (in the Form_Current event) to control visibilty when you return to a record.
We really do need to see the code you've got so far.
BTW, ajetrumpet, Yes/No or True/False will both work with .Visible.
Welcome to TheScripts!
Linq ;0)>
Thanks guys. Sorry I wasn't clear on my earlier post. I didn't try to write any code to turn visible to off. I went to properties for the field as outlined above. The mistake I made was that I wasn't in Design View. Doh! A beginners mistake for sure. I figured it out on my own last night toying around with it.
Ok, after that was fixed, I tried to write some code using the code provided in the first response as a guideline. It worked but there are some bugs that I noticed right away.
1. After making a selection from the combo box in one record, the resulting field appears as it's supposed to, but it shows up in all records instead of just the current one.
2. If I change the selection in the combo box, the field from the earlier selection remains instead of going away.
I'm not a code writer, so I need some help with that! Many thanks!
edit: oops, almost forgot to post my code that I have so far. Here ya go: -
Private Sub Property_Found_By_AfterUpdate()
-
-
If Me.Property_Found_By = "Realtor" Then
-
Me.Realtor_Name.Visible = True
-
Me.Realtor_Phone_Number.Visible = True
-
-
ElseIf Me.Property_Found_By = "Driving" Then
-
Me.Driving_Date.Visible = True
-
-
ElseIf Me.Property_Found_By = "Mailing" Then
-
Me.Mailing_Date.Visible = True
-
-
ElseIf Me.Property_Found_By = "Other" Then
-
Me.Explanation.Visible = True
-
End If
-
-
End Sub
I fixed #2 with this code: -
Private Sub Property_Found_By_AfterUpdate()
-
-
If Me.Property_Found_By = "Realtor" Then
-
Me.Realtor_Name.Visible = True
-
Me.Realtor_Phone_Number.Visible = True
-
Me.Driving_Date.Visible = False
-
Me.Mailing_Date.Visible = False
-
Me.Explanation.Visible = False
-
-
ElseIf Me.Property_Found_By = "Driving" Then
-
Me.Realtor_Name.Visible = False
-
Me.Realtor_Phone_Number.Visible = False
-
Me.Driving_Date.Visible = True
-
Me.Mailing_Date.Visible = False
-
Me.Explanation.Visible = False
-
-
ElseIf Me.Property_Found_By = "Mailing" Then
-
Me.Realtor_Name.Visible = False
-
Me.Realtor_Phone_Number.Visible = False
-
Me.Driving_Date.Visible = False
-
Me.Mailing_Date.Visible = True
-
Me.Explanation.Visible = False
-
-
ElseIf Me.Property_Found_By = "Other" Then
-
Me.Realtor_Name.Visible = False
-
Me.Realtor_Phone_Number.Visible = False
-
Me.Driving_Date.Visible = False
-
Me.Mailing_Date.Visible = False
-
Me.Explanation.Visible = True
-
End If
-
-
End Sub
-
I have no clue on how to fix #1 though. Maybe the answer is what missing said:
"You'll also have to save one of these 4 designations to each record, and use that (in the Form_Current event) to control visibilty when you return to a record."
I don't know what that means though. Can you give a detailed explanation?
Just to be clear, my problem now is the appearance of the fields as I move from record to record. The combo box selection is correctly saved in each record as I leave and come back but the resulting fields are not. For example, if I choose "Driving" from the combo box in record #1 then the field "Driving Date" appears. If I then move to record #2 the field "Driving Date" is still visible even though "Driving" was never selected from the combo box in this record. I hope I explained that well enough. Thanks!
Just wanted to bump up my question just in case it had fallen through the cracks over the weekend.
OK! You say that Property_Found_By is being saved for each record, so now, as you move from record to record, you need to check its value and set the visbility of fields accordingly. - Private Sub Form_Current()
-
If Me.Property_Found_By = "Realtor" Then
-
Me.Realtor_Name.Visible = True
-
Me.Realtor_Phone_Number.Visible = True
-
Me.Driving_Date.Visible = False
-
Me.Mailing_Date.Visible = False
-
Me.Explanation.Visible = False
-
-
ElseIf Me.Property_Found_By = "Driving" Then
-
Me.Realtor_Name.Visible = False
-
Me.Realtor_Phone_Number.Visible = False
-
Me.Driving_Date.Visible = True
-
Me.Mailing_Date.Visible = False
-
Me.Explanation.Visible = False
-
-
ElseIf Me.Property_Found_By = "Mailing" Then
-
Me.Realtor_Name.Visible = False
-
Me.Realtor_Phone_Number.Visible = False
-
Me.Driving_Date.Visible = False
-
Me.Mailing_Date.Visible = True
-
Me.Explanation.Visible = False
-
-
ElseIf Me.Property_Found_By = "Other" Then
-
Me.Realtor_Name.Visible = False
-
Me.Realtor_Phone_Number.Visible = False
-
Me.Driving_Date.Visible = False
-
Me.Mailing_Date.Visible = False
-
Me.Explanation.Visible = True
-
End If
-
Linq ;0)>
Wow, that was a quick response! Thank you missing. I implemented your code and it worked like a charm! Two more quick questions have arisen:
1. What about when the "Property Found By" Combo Box is empty or null? I need to write some code so that in this case, there are no additional fields shown. As it stands now, if I switch the comb box to empty, the fields from the last choice made remain.
2. When you open up that little window where you can write code, there is a dropdown menu in the upperleft (all the fields, form etc) and then a dropdown menu in the upper right that contains all the possible events, I'd like to learn more about all the stuff in these dropdown menus. I never would have been able to find that form_current that you suggested on my own. Perhaps there is a tutorial that explains in detail all the possible choices in these dropdown menus? What each one does etc.
I tried this code for when the combo box is empty but it didn't work:
ElseIf Me.Property_Found_By = "" Then
Me.Realtor_Name.Visible = False
Me.Realtor_Phone_Number.Visible = False
Me.Driving_Date.Visible = False
Me.Mailing_Date.Visible = False
Me.Explanation.Visible = False
Try:
ElseIf IsNull(Me.Property_Found_By) Then
Me.Realtor_Name.Visible = False
Me.Realtor_Phone_Number.Visible = False
Me.Driving_Date.Visible = False
Me.Mailing_Date.Visible = False
Me.Explanation.Visible = False
Linq ;0)>
Perfection! Thank you missing! You were a big time help. I appreciate it.
Glad we could help! As far as the questions about the code window (VBA code editor.)
Select an object from the left hand window, then the right hand dropdown box will offer all the events available for that object. To find out what each event entails, fire up Access Help (I personally whistle for Rocky the Access Hound) and enter the search term Events. Then click on Events and Event Property References and there you have it! A list of all of them. Linq ;0)>
Glad we could help! As far as the questions about the code window (VBA code editor.)
Select an object from the left hand window, then the right hand dropdown box will offer all the events available for that object. To find out what each event entails, fire up Access Help (I personally whistle for Rocky the Access Hound) and enter the search term Events. Then click on Events and Event Property References and there you have it! A list of all of them. Linq ;0)>
Perfect. That should be helpful in the future. Thanks again!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: sao |
last post by:
I am currently using Access 2000.
In my table it is the following fields that are set up:
1 - Staff Name
2 - Department
This table is already populated with 100+ records (staff along with...
|
by: news.hp.com |
last post by:
I have situation where I need to copy multiple records (only certain fields)
from a Rules table to an Events table based on a selection identified in a
combo box. When the selection is made in a...
|
by: KB |
last post by:
I am creatig a database in 2000 where I need to be able to have the
users add data and information into lookup tables. That is no
problem, I have a form for that, that works fine. This...
|
by: Cro |
last post by:
Dear Access Developers,
I am developing a form with 'default view' set to "continuous forms".
I am suffering with a problem I can't yet see a solution too.
Each record has many fields. Two...
|
by: ISmith |
last post by:
Hi,
I have two comboboxes on a master form. I need to link them together so
that combobox a's on change will update combobox b with maching records and
visa versa.
Then when a button is...
|
by: Dan Cook |
last post by:
Ok... here's the scoop... I've got an unbound form with Serial Number,
Building, and Room... all this is in tableA... Now I've got the form
setup with building, room and serial number as combo...
|
by: Birderman |
last post by:
Hi
is it possible to enter data into two separate fields from a single combo
box selection.
ie if select entry in combo, field 1 will be filled with data from column 1
of combo and field2...
|
by: joseph.mccastlain |
last post by:
Hello All,
I am a new user to Access. I am currently designing a database
consisting of four tables for multiple users. Rather than bore you
with the goals and such, here is what I am...
|
by: peasedm |
last post by:
Okay this one has me stumped. I have a table called Review_Statements
with the following columns:
statementid
type
statement1
statement2
statement3
I have a form called SR_Review with an...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |