Link to home
Start Free TrialLog in
Avatar of gigifarrow
gigifarrow

asked on

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
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Avatar of gigifarrow
gigifarrow

ASKER

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.
I'm afraid the file you posted is not usable except to look at tables.
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.
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...?
here is the original Database, sorry for the inconvience.
Sorry, here it is.
Copy-of-Inventory-db.accdb
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
Should I use a lookup command? Where do I put the name of my fields in your code?
<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.
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.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
...?

I'm confused by your post.

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


enjoy the weekend

Jeff