?
Solved

Populating fields based on input of another field.

Posted on 2012-03-27
20
Medium Priority
?
263 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

765 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