Opening a report in code in Access 2000 and 2002

D

David Brown

Is there any reason the following code would not work on an Access 2000
machine?

Thanks for the help,

David Brown


Private Sub cmdViewVisits_Click()
On Error Resume Next
stDocName = "rpt_PatientVisits"
stWhere = "visit_PatKey =" & Me.txtKey
If Me.txtKey = "" Then
MsgBox "Please select a Site and Patient Name", , "Patient Info"
Exit Sub
End If
DoCmd.OpenReport stDocName, acPreview, , stWhere
If Err = 2501 Then Err.Clear

End Sub
 
M

Marshall Barton

David said:
Is there any reason the following code would not work on an Access 2000
machine?

Private Sub cmdViewVisits_Click()
On Error Resume Next
stDocName = "rpt_PatientVisits"
stWhere = "visit_PatKey =" & Me.txtKey
If Me.txtKey = "" Then
MsgBox "Please select a Site and Patient Name", , "Patient Info"
Exit Sub
End If
DoCmd.OpenReport stDocName, acPreview, , stWhere
If Err = 2501 Then Err.Clear

End Sub


Probably a million reasons ;-)
What kind of error are you getting?
Just guessing now, but shouldn't the missing criteria check
be:
If IsNull( Me.txtKey) Then
 
D

David Brown

I won't be able to talk to the end user again until tomorrow so I'm not sure
of the specific error. I don't think they are getting a run time error
though. I agree the missing criteria check should be changed and that the
trouble could be anywhere. However, I just got through an issue where a
block of code worked great in Access 2002 but not in Access 2000. I'm in the
same situation here in that the code works great in Access 2002 but I'm not
sure about Access 2000. I'm curious to know if anything I've done here looks
like it might need to be reworked in order to be Access 2000 compatible.

Thanks for the insight,

David Brown
 
M

Marshall Barton

If that code works in one version, it should work in the
others. That might be a big IF, but I don't see anything in
there that's version dependent.
 

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.

Ask a Question

Top