Populating fields based on input of another field.

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
gigifarrowAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

peter57rCommented:
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.
gigifarrowAuthor Commented:
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.
peter57rCommented:
I'm afraid the file you posted is not usable except to look at tables.
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Helen FeddemaCommented:
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.
Jeffrey CoachmanMIS LiasonCommented:
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...?
gigifarrowAuthor Commented:
here is the original Database, sorry for the inconvience.
Jeffrey CoachmanMIS LiasonCommented:
?
gigifarrowAuthor Commented:
Sorry, here it is.
Copy-of-Inventory-db.accdb
Jeffrey CoachmanMIS LiasonCommented:
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
gigifarrowAuthor Commented:
Should I use a lookup command? Where do I put the name of my fields in your code?
Jeffrey CoachmanMIS LiasonCommented:
<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.
gigifarrowAuthor Commented:
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.
Jeffrey CoachmanMIS LiasonCommented:
<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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gigifarrowAuthor Commented:
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
Jeffrey CoachmanMIS LiasonCommented:
...?

I'm confused by your post.

You downloaded my sample and tested it.
Did it work the way you wanted?
Yes or No?
gigifarrowAuthor Commented:
Yes, I down loaded the sample database but I dont see where you put the code or the form with the code?
Jeffrey CoachmanMIS LiasonCommented:
<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)
gigifarrowAuthor Commented:
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.
Jeffrey CoachmanMIS LiasonCommented:
Great,


enjoy the weekend

Jeff
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.