Solved

Populating fields based on input of another field.

Posted on 2012-03-27
20
253 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
Comment Utility
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
Comment Utility
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
Comment Utility
I'm afraid the file you posted is not usable except to look at tables.
0
 
LVL 31

Expert Comment

by:Helen_Feddema
Comment Utility
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
Comment Utility
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
Comment Utility
here is the original Database, sorry for the inconvience.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
?
0
 

Author Comment

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

Expert Comment

by:Jeffrey Coachman
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:gigifarrow
Comment Utility
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
Comment Utility
<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
Comment Utility
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
Comment Utility
<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
Comment Utility
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
Comment Utility
...?

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
Comment Utility
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
Comment Utility
<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
Comment Utility
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
Comment Utility
Great,


enjoy the weekend

Jeff
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now