Combo Box Coding


H

Hale

Okay here's the question, it's probably a simple one for everyone here, but
I've been trying for over a month now and can't get this right. I have a
form, and on this form there is a combo box at the top with the names of
certain people, and below that are text boxes which should have something
other than #NAME in them. These names were taken from a table from the same
databse (obviously). Also on the table are other pieces of information about
them (coulmns) that have their first name, last name, city, state, zip, etc.
In case anybody doesn't yet get where I'm going with this, the form is
(supposed to be) a mirror of the table, but I want to have it so that when
you click someone's name on the combo box in the form, all the other info
magically appears in the text boxes below the combo box. I have been working
with this: http://www.access.qbuilt.com/html/find_a_record.html , and it is
exactly what I want to do, but it's not working for me. Can anyone help me,
please? Thanks
 
Ad

Advertisements

J

Jeff Boyce

Hale

You're not giving us much to go on ... "it is exactly what I want ... but
it's not working..."

Care to elaborate?

(by the way, any chance that combobox at the top is bound?)

Please provide more description for more specific suggestions.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
H

Hale

Sorry for lack of clarity. By "what I want", I meant that the link to the
"find a record" example is what I'm trying to do with my database. I'm trying
to use the combo box as a source for someone to click on, and then see the
other information associated with that someone filled in the corresponding
text boxes on the form. Right now, the names don't show up in the combo box
on my form and all the text boxes have the "#NAME" message inside of them.
And how do I make a combo box "bound" to something? I most likely forgot that
step. Thank you.
 
Ad

Advertisements

J

Jeff Boyce

Actually, I was hoping the combobox was NOT bound.

Here's the approach I use, which sounds quite a bit like what you're
describing. Can you confirm you are doing the same things...?

* create a query that returns all the fields I want to see from a table
(your person/info table)
* create a form that is "fed" by the query. Add the fields as controls.
* add a new control in the header. Make this a combobox. "Feed" the
combobox from a query which returns the PersonID, PersonName, and any other
fields helpful in identifying which one you want to select.
* set the number of columns of the combobox to the number of fields
returned.
* set the width of the first column to 0 (that's the PersonID field), the
rest as wide as needed
* modify the query that "feeds" the form -- in the selection criterion
under the PersonID field, use something like:
Forms!YourFormName!cboYourComboboxName
* in the combobox's AfterUpdate event, add something like:
Me.Requery

So here's the sequence of events ...

1) you open the form
2) the form uses its query, looks for record(s) with the PersonID = the
PersonID selected in the combobox -- big surprise! none has been selected
yet, so no record is displayed!
3) select a person from the combobox and hit <Enter> or <tab>
4) the form fires the combobox's AfterUpdate event which
5) re-runs the query that feeds the form, which
6) now finds a PersonID in the combobox, so finds the record with that
PersonID, and
7) loads the form with that person's information.

Note that the form has to be open for this to work.

Is that what you're trying to do? Is that what you're doing?

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top