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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run - time Error 2501 - MS Access Form cmd button 1

Status
Not open for further replies.

NJko4

MIS
Mar 8, 2008
13
US
Not able to resolve a run-time error using MS Access 2003. Upon clicking on a command button on a MS Access form, I receive a run-time error.

Upon accessing the code, the line beginning with DoCmd.OpenReport... is highlighted.

Any idea on the source/resolution of the problem?

Private Sub Command42_Click()
'Original Line immediately below
' DoCmd.OpenReport "Project Summary", acViewPreview, , "[ProjectID] = " & [ProjectID] '"[ProjectID] = " & [ProjectID]

DoCmd.OpenReport "Project Summary", acViewPreview, , "CurrentProjectID = " & [ProjectID] '" 'Modified Line"

' CurrentProjectID = [ProjectID] 'DoCmd.OpenReport "Project Summary", acViewPreview 'Doesn't work

End Sub



 
hi

I think you have a ' where you shouldn't

DoCmd.OpenReport "Project Summary", acViewPreview, , "CurrentProjectID = " & [ProjectID] '"

Should be :

DoCmd.OpenReport "Project Summary", acViewPreview, , "CurrentProjectID = " & [ProjectID]



Hope this helps!

Regards

BuilderSpec
 
As it's a comment line it shouldn't affect the OpenReport call.

What kind of datatype is CurrentProjectID expecting, if it's not Numeric that would cause problems with the current method.

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
No code in the NoData event procedure of the report setting the Cancel parameter to True ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I can view the reports while at work but cannot view on the laptop from home.

I have MS Access 2002 at work and MS Access 2003 on the laptop.

References on the computer at work are;
Visual Basic For Applicatons
Microsoft Access 10.0 Object Libary
OLE Automation
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.8

References for the MS Access 2003 database on the laptop are the same except the object library reference is Microsoft Access 11.0 Object Libary.

Any thoughts as to a resolution to this issue?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top