My form2 is a start form, there is a combo box named year on it. The form2
contains a sub form; I would like to change the sub form’s Record Source to
open each query displaying records on sub form corresponding to the year
selected from the combo box on the Start form. Here is the code for sub form
which I have now, it does not work. The message I got is the unknown form
Start. Please help me for the code. Thanks!
Private Sub Form_Load()
Dim year As String
year = Forms!Start!cboYear
year = Right(year, 2)
year = CStr(year)
Me.RecordSource = "q" & year & "Sum_US" ‘It is the query’s name
which I like to connect to
This is very different from your original question. And, you have a design
flaw that needs addressing. It is not necessary to have a different query
for each possible year.
Use one query that filters on the value in the combo box.
Then use the After Update event of the combo to requery the subform.
Me.MySubformControl.form.requery
Each query is generated by different calculations, there are not on one
query. The way I would like to connected the query because of that reason. Is
that possible to connect the query like that?
What do you mean by " generated by different calculations"?
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.