Combo boxes and search forms

A

allie357

I have a bunch of combo boxes that are unbound and get their values
from this type of query:
In this particular example it takes the violator_ID and name from the
violator's table and displays just the name.
SELECT tbl_Violators.Violator_ID, [Violator's Last Name] & ", " &
tbl_Violators![Violator's First Name] AS [Violator's Name] FROM
tbl_Violators ORDER BY tbl_Violators.[Violator's Last Name];

But I need to be able to use the combo to search the violations table
where the violations ID is stored as a foreign key.
I need to know if it's possible to just look at the violator_ID value
in the combo and comparing it to the equal id fk in the violations
table and display them in a subform. I do not have lookup fields, just
primary and foreign keys. I need to build the search/edit form for the
violations table.
 
J

J. Goddard

To refer to the violator_Id in the combox box, use: combo_box.column(0)
Is that what you are asking?

John
 
A

allie357

Yes that helps. How would I code it to search the combo box and get
results to display the records with the matching values? That is where
I am stuck.

Thanks in advance for any advice.


J. Goddard said:
To refer to the violator_Id in the combox box, use: combo_box.column(0)
Is that what you are asking?

John

I have a bunch of combo boxes that are unbound and get their values
from this type of query:
In this particular example it takes the violator_ID and name from the
violator's table and displays just the name.
SELECT tbl_Violators.Violator_ID, [Violator's Last Name] & ", " &
tbl_Violators![Violator's First Name] AS [Violator's Name] FROM
tbl_Violators ORDER BY tbl_Violators.[Violator's Last Name];

But I need to be able to use the combo to search the violations table
where the violations ID is stored as a foreign key.
I need to know if it's possible to just look at the violator_ID value
in the combo and comparing it to the equal id fk in the violations
table and display them in a subform. I do not have lookup fields, just
primary and foreign keys. I need to build the search/edit form for the
violations table.
 
J

J. Goddard

This is the technique I use in one of my home databases. Assuming that
the violator_id is in a bound control on the main form, and that the
Master Field and Child Field links are the Violator_id, you can do this:

DoCmd.GoToControl "Violator_Id"
DoCmd.FindRecord Me![your_combo_box].Column(0), acEntire, , acSearchAll

Not the best way, maybe - but it works.

John

Yes that helps. How would I code it to search the combo box and get
results to display the records with the matching values? That is where
I am stuck.

Thanks in advance for any advice.


J. Goddard said:
To refer to the violator_Id in the combox box, use: combo_box.column(0)
Is that what you are asking?

John

I have a bunch of combo boxes that are unbound and get their values
from this type of query:
In this particular example it takes the violator_ID and name from the
violator's table and displays just the name.
SELECT tbl_Violators.Violator_ID, [Violator's Last Name] & ", " &
tbl_Violators![Violator's First Name] AS [Violator's Name] FROM
tbl_Violators ORDER BY tbl_Violators.[Violator's Last Name];

But I need to be able to use the combo to search the violations table
where the violations ID is stored as a foreign key.
I need to know if it's possible to just look at the violator_ID value
in the combo and comparing it to the equal id fk in the violations
table and display them in a subform. I do not have lookup fields, just
primary and foreign keys. I need to build the search/edit form for the
violations table.
 

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