Combo box selection limited to current record

goldriverdancer

Registered User.
Local time
Tomorrow, 07:29
Joined
Jan 4, 2010
Messages
13
Dear all,

I have a problem that I've been trying to solve for some time. :( I have a combo box on my main form [PCP Database] which is linked to a secondary table [Well files] which contains 3 fields: a foreign key, file name and file path. The primary key on the main form "Well name" is linked in a 1 to many relationship to the foreign key in the secondary table.

When a user clicks on one of the file names displayed in the dropdown list, the corresponding file will open. I want only the file names for the current record to be displayed when i click on the dropdown list. Right now, my row source for the combo box looks like this:

SELECT [Well Files].[Well name], [Well Files].[File Name], [Well Files].[File Path] FROM [Well Files]
WHERE [Well Files].[Well name]=Forms![PCP Database].[Well name];

I thought that this row source would force the combo box to only display the file names where the field "Well name" in [Well Files] corresponded with the same field in [PCP Database]. However, right now, I have 2 files for the first record being displayed for all the records.

Can anyone help?

Much appreciated.
 
Requery the ComboBox in the OnEnter or GotFocus event of the ComboBox:
Me.[PCP Database].Requery
 
Awesome, it's working perfectly now! Thanks heaps. =)

Stef
 

Users who are viewing this thread

Back
Top Bottom