About the recordsource property

Posted on 2003-03-07
Medium Priority
Last Modified: 2008-02-01

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
Question by:originalrobby
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Author Comment

ID: 8089279
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 & "';"

Expert Comment

ID: 8089309
recToGo is a control in the "main" form, right?

Expert Comment

ID: 8089322
recToGo is a control in the "main" form, right?
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

LVL 41

Accepted Solution

shanesuebsahakarn earned 400 total points
ID: 8089434
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>

Expert Comment

ID: 8089439
sometimes you say recGoTo and sometimes you say recToGo; is it as simple as maybe you are spelling it wrong? ;)

Expert Comment

ID: 8089469
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).

Author Comment

ID: 8089485
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question