By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,761 Members | 1,878 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,761 IT Pros & Developers. It's quick & easy.

Passing parameter to rowsource of combo box dynamically

P: 3
I have a main form which contains questions and a subform within it which contains elements which relate to the main form. they are linked by a field called question_ref so if I page through the records on the main form the elements that are relevant to that question display in the subform.

Within the subform I have a combo box which calls a table which contains the following question_ref and a text field. I would like to be able to make the combo box only display data in the combo box that relates to the current question in the subform.

I have tried setting the rowsource of the combo box as following but is does not display any values.(error enter parameter me.question_ref)
Expand|Select|Wrap|Line Numbers
  1. select tbllookup_comment.question_ref,
  2.        tbllookup_comment.text
  3. from tbllookup_comment
  4. where tbllookup_comment.question_ref = me.question_ref (this is a field in my subform)
Any ideas why it is not picking up the data from the me.question_ref field and passing across to the rowsource.

Any help greatly appreciated
Jan 6 '09 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 15k+
P: 31,489
Me. is an object reference that works within VBA. It is entirely unknown to (unrecognised by) the SQL interpreter.

It should recognise a fully qualified reference though. The form must be open of course (You may find Referring to Items on a Sub-Form useful).
Jan 6 '09 #2

P: 3
Hi Thanks for that
I can now get the combo box to display the options for question1 correctly but when I go to the next record in the subform it shows me options in the combo box for the previous record so its not refreshing the combo box as it goes through the records in the sub form, it there someother code I need to do this
Jan 6 '09 #3

Expert Mod 15k+
P: 31,489
The SQL doesn't keep repeating its execution.

If the criteria change somehow, and you want to reprocess the query, you need to call a .Requery on the object (You only refer to it as a ComboBox on your SubForm) that the SQL is in.

Does that make sense?
Jan 6 '09 #4

P: 3
Great thanks for your help thats owkred
Jan 6 '09 #5

Expert Mod 15k+
P: 31,489
Great :)

I'm always pleased when something owkrs (LOL).

J/K We all live on typos here ;)
Jan 6 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.