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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box of "Find a value based..." in a form with related tables 2

Status
Not open for further replies.

MSWhat

IS-IT--Management
Jul 19, 2007
62
US

I am creating a form off of two tables, joined in a query, "Conglomerate," which serves as the recordsource for my form. Before I expanded into a second table, I had a combo box at the top of the page to find values based off of what they began to type in. This served as a really easy way for my clients to toggle between the hundreds of records without having to scroll through with their mouse wheel or do a Ctrl>F. However, since I've added a second table and related it to the first, I haven't been able to set up this combo box. Whenever I do, the list comes up in the combo box when I view it in form view, however whenever I select a record form the list, instead of taking me to that record an error message reading "Run-time error 3345: Unknown or Invalid Field Reference [MasteList.Transaction Name] pops up.
 
What is the code on the afterupdate of the combobox?

What is the SQL for the recordsource of the form?

Which table in the recordsource is on the one side of the relationship?
 
Thanks for jumping in, Iameid. How do I retrieve the code on the afterupdate combobox? The SQL for the recordsource?

Sorry. I'm new to Access, this being my first project, and don't know quite what you mean.

It's a one-to-one relationship,so I'm assuming they're both classified as the "one side"? The MasterList table hosts the Primary Key, Bank Account Info table hosting the Foreign Key.

Sorry for the ignorance, but thanks for the help.
 
To find the code, open the form in design view. Select "View" and "Code". You will see the code associated with each command on your form. Hope this helps a little.
 
Also, recordsource is a property.

In design view select the form or control and from the view menu select properties (or right click and select properties).

The recordsource will be either a table or query.
If it is a query please open it and switch to SQL View (the button that toggles Design and datasheet is also a drop down). Post the SQL.
 
The recordsource of the from is a query, Conglomerate, which has the following code:

SELECT [Master List].*, [Bank Account Info].*
FROM [Master List] INNER JOIN [Bank Account Info] ON [Master List].[Transaction Name] = [Bank Account Info].[Transaction Name];


The afterupdate code of the combo box is:
Private Sub Combo1104_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Master List.Transaction Name] = '" & Me![Combo1104] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub




THANKS BRIAN AND LAMEID FOR YOUR HELP! TOTALLY LOST AND COMPLETELY GRATEFUL.
 
The following line is incorrect...

Code:
rs.FindFirst "[Master List.Transaction Name] = '" & Me![Combo1104] & "'"

Replace with this:

Code:
rs.FindFirst "[Master List].[Transaction Name] = '" & Me![Combo1104] & "'"
 
Brilliant! Thanks SO much, LameID.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top