Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error Err 2001

Status
Not open for further replies.

mundia22

ISP
Apr 23, 2002
17
0
0
GB
hi guys can anyone SPOT the error

Private Sub cmdOK_Click()
Form_Company.RecordSource = "SELECT * FROM Company WHERE CompanyID = '" & Me.CompanyID & "' "
DoCmd.Close
End Sub

what i am trying to do is to make the company form goto the same record that I am looking at on different form but I get the Above error '2001' you canceled the previous operation..Any ideas what acces is moaning on about..
 
Hi

Assuming the cmdOK button is NOT on Form_Company

Then you cannot reference Form_Company in that way, the form must be open and you need Forms!Form_Company..etc

But in any case, I do not think you can change the recordsource of Form_Company at that point (not sure about that), I would normally do it in the on open event of the form Form_Company

Me.RecordSource = "SELECT * FROM Company WHERE CompanyID = '" & Forms!OtherForm.CompanyID & "' "
Me.Requery


Private Sub cmdOK_Click()
Form_Company.RecordSource = "SELECT * FROM Company WHERE CompanyID = '" & Me.CompanyID & "' "
DoCmd.Close
End Sub

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top