Solved

Populating fields based on input of another field.

Posted on 2012-03-27
20
259 Views
Last Modified: 2012-04-05
I have a form called, "frmVehicleInduction". Based on the serial number I need to have the form to just show what pertains to that serial number. For example, 3AGRO250Y should only show the following fields: BFT InstallLocation,BRAT installed, and BRAT II installed.
Copy-of-Inventory-db.accdb
0
Comment
Question by:gigifarrow
  • 8
  • 8
  • 2
  • +1
20 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 37771535
I don't see how you know which fields are to be visible before you have created the record?

And I don't see how you can test for a specific serial number unless you know in advance which serial numbers you are going to get?

Please explain.
0
 

Author Comment

by:gigifarrow
ID: 37771672
If you look on the form serial numbers are already inputted. There is a drop down for the serial numbers. The form has all the fields possible. I gave you a serial number that is in the drop down. Then I gave you the fields that need to be shown when that serial number is inputted.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37771697
I'm afraid the file you posted is not usable except to look at tables.
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 37771821
Run some code from the AfterUpdate event of the combo box used to select a serial number, and also from the Current event of the form, to make the appropriate controls visible or invisible depending on the serial number.  A Select Case statement would be best if there are more than two serial numbers that need special treatment.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37771831
Yes, please check the file you uploaded, I keep getting Index errors

Run the compact repair utility
Compile the code

You literally have a Error table in this db. (MSysCompactError)
Why not fix these errors, then post a "clean" db for us to examine...?
0
 

Author Comment

by:gigifarrow
ID: 37772017
here is the original Database, sorry for the inconvience.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37772024
?
0
 

Author Comment

by:gigifarrow
ID: 37772191
Sorry, here it is.
Copy-of-Inventory-db.accdb
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37772646
You can certainly "Hide" all blank controls...
But if you want to dynamically "Condense" all non-empty controls together, then that is going to be complex.


To hide all empty controls, use code like this on the current event of the form:

Dim ctl As Control

If Not Me.NewRecord Then
    For Each ctl In Me.Section(0).Controls
        If ctl.ControlType = acTextBox Then
            If IsNull(ctl) Or ctl = "" Then
                ctl.Visible = False
            Else
                ctl.Visible = True
            End If
        End If
    Next ctl
End If


JeffCoachman
0
 

Author Comment

by:gigifarrow
ID: 37773220
Should I use a lookup command? Where do I put the name of my fields in your code?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37773533
<Should I use a lookup command? >
No

<Where do I put the name of my fields in your code?>
No need, the code just loops through all the textboxes and makes any control that is blank invisible.
0
 

Author Comment

by:gigifarrow
ID: 37782559
None of these codes work. Maybe I should explain it more clearly. You have a form with fields in it. You want to just type the serial number and then the other fields should pop up with the information that pertains to that serial number.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 37783361
<None of these codes work.>
Instead of saying "these codes work.", please post what you tried...(and what the exact results were)
Perhaps it is just a syntax issue.

Oh, so you have actually 2 questions here, not one:
1. Create a system to filter for a serial number
2. Create a system to only show non empty fields....

AFAICT my code will do as you requested with a minor mod to filter.
But instead of relying on a user to "Type" in a serial number, I will simply provide a combobox where they can "Select" the serial number...

If you do in-fact want the Blank field to be hidden, then note that I stated that "Condensing" all of the non-blank fields together on the form will be extremely complex in the forms current design.

If you don't want this (and all you really want is to simply filter the form for the selected serial), then delete the code to hide the controls.

See attached DB file

JeffCoachman
Copy-of-Inventory-db.accdb
0
 

Author Comment

by:gigifarrow
ID: 37783720
Thank you for your help. I would like a combo box with all the list of  serial numbers. The code that i was given was put on a form and no syntax error showed when I tried to use it.  It just didnt work.  On my database what form did you do the code on? I dont see it.

Sincerely,
Gina
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37783803
...?

I'm confused by your post.

You downloaded my sample and tested it.
Did it work the way you wanted?
Yes or No?
0
 

Author Comment

by:gigifarrow
ID: 37784121
Yes, I down loaded the sample database but I dont see where you put the code or the form with the code?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37784241
<I don't see where you put the code or the form with the code?>
You don't even see the form?!
"frmVehicleInduction"


Open the database
Press Alt+F11 (to see the code)
0
 

Author Comment

by:gigifarrow
ID: 37784649
Okay, Thank you. Yes, it does work. You are great. You always give me the right answer!

I am going to study the code so that I can do it myself.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37787538
Great,


enjoy the weekend

Jeff
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question