• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

About the recordsource property


I have several tables, and several forms (with one main form), each form has its own table. All of those forms/tables keep information about a single project so I need to be able to display the same project when a user goes from one form to another. I am trying to control the recordsource property of each form to display the record id that is coming from the main form. I've tried everything from putting the id on the main form(which is auto generated) in a variable so that I can then use an SQL statement in my other forms to bring the id that matches the main form.

Anyways to keep it short, when I do

it always says error 2001 "You cancelled the previous operation".

I just cannot seem to get it to select the record that I want it to based on what the variable recGoTo contains.

If I take out the single quotes it will ask me for the parameter value of recToGo then it will go to the right record.

Any help would be greatly appricated because this is driving me nuts!

Thank You
Robert Mezei
1 Solution
originalrobbyAuthor Commented:
Sorry, a small mistake in rushing I've tried both of these SQL statements:

Form_frmSecOps.RecordSource = "SELECT * FROM SECTIONV WHERE SECTIONV.RecordID = 'recToGo';"

Form_frmSecOps.RecordSource = "SELECT * FROM SECTIONV WHERE RecordID='" & recGoTo & "';"
recToGo is a control in the "main" form, right?
recToGo is a control in the "main" form, right?
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Forms!frmSecOps.RecordSource = "SELECT * FROM SECTIONV WHERE RecordID=" & recGoTo & ";"

Is RecordID a number or a text field ? The above is for a numeric field. If recGoTo is a *control* name, try:
Forms!frmSecOps.RecordSource = "SELECT * FROM SECTIONV WHERE RecordID=" & Me!recGoTo & ";"

Also, is frmSecOps opened as a subform or a main form ? If it is a subform, you can't directly refer to it in this way. You'll need to do something like:
Forms!MainFormName!SubformControlName.Form.RecordSource = <your SQL statement>
sometimes you say recGoTo and sometimes you say recToGo; is it as simple as maybe you are spelling it wrong? ;)
So when you take out the quotes, it asks for the parameter, but if you type in the correct RecordID, you get the correct results right? If so, might the variable contain the wrong data?  Also, if there is only 1 record on the main form, you could have all the secondary forms reference the original form via the query builder. If you put criteria in your query builder of the secondary forms, something like:


Then it should use the recordID from the main form as the criteria for the secondary form (main form must remain open).
originalrobbyAuthor Commented:
Dudes, you're all so damn good!

I just graduated recently and don't have much experience.

Although I already figured it out, I am accepting this answer man, because it's close! Thanks alot guys, this is what i got:

sqlString = "SELECT * FROM [SectionV] WHERE [RecordID]=" & Forms!frmSales!frmSecOpsRecID & ";"

Form_frmSecOps.RecordSource = sqlString

same thing I guess, either way it works! lol

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now