Set recordsource by a list of queries in combobox

coasterman

Registered User.
Local time
Today, 07:06
Joined
Oct 1, 2012
Messages
59
I have a dozen or so queries which I intend to filter a main forms underlying data. This qry count will doubtless increase with development.

Rather than have a dozen buttons on my form I'm trying to have a combo box list the names of the queries for the user and once a particular query has been selected that then becomes the Record Source for the form.

The query names are probably not that user friendly so I created another table with fields as follows

qryNameID
qryName (the actual name of the query in the project)
FriendlyqryName

I then made that table the row Source for an unbound combo box and put this on my main form frmReferral

This is where I get stuck:

I have played around with some code along the lines of, and this I should say is without any great confidence that the method is correct.

Code:
Me.RecordSource = Me.cboQueryPicker.Column(2)

I guess this would be a pretty common task so apologies if this has been covered before and my search keys didn't throw up the relevant thread.

P.S is it possible to simply set the record source of the form in the property sheet directly by referencing the relevant column of a combo box? If so what would be the correct syntax?

Thanks for looking
 
The only problem I see is that the columns are zero based so if this is the order of the columns in the combo box then their indexes are

qryNameID = Column(0)
qryName = Column(1)
FriendlyqryName = Column(2)

so your code should be:

Me.RecordSource = Me.cboQueryPicker.Column(1)
 
Knowing I was at least in the vicinity I tracked my problem down to using the wrong event type, should as I now rather embarrassingly realise should not be the before event.. Thanks for narrowing the search!
 

Users who are viewing this thread

Back
Top Bottom