Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing tables in VBA that are not source tables for a form

Status
Not open for further replies.

nottus

Programmer
May 19, 2008
1
AU
I want to know how I can reference 2 other tables from within a form using VBA. The 2 other tables are not related to the form's record source property and are not related to the form's record source. The data in the other tables needs to be selected by values in the forms source table. I think I did this a long time ago with Access 2.0 but I've forgotten how and I don't have access (pardon the pun) to this older database.
 
A common way is to use a query. Other options include comboboxes & listboxes, DlookUp and recordsets. It all depends on what you want to do.
 
The data in the other tables needs to be selected by values in the forms source table

To continue what Remou said and based on above, it sounds like a listbox or combo box is what you are after. The row source of a list or combo can be any query or a value list. For example you have a data table of people and a table of colors. If there is a field in the people table for a person's favorite color you can use a list box or combo to display the colors from the color table. Often however, you want to show the color but save a primary key into your data table. This is done by haveing the qry return the key and the color description and binding the control to the key. Then format the the list/combo to hide the key but show the description.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top