Solved

Populating fields based on input of another field.

Posted on 2012-03-27
20
261 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

688 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