What am I not seeing?

R

r. howell

I have two procedures. One does what I expect it to (opens the report showing
the appropriate data based on the "stWhere" string. The second produces
"error#" where the data should be in the report. The two stWhere's are

This one works:
stWhere = "([StDate]=#" & Me.StDate & "#) “

This one doesn't work:
stWhere = "([EndDate]=#" & Me.txtEndDate & "#) “

I can't see the difference that could be causing the problem.
Anyone else see the problem?
Thanks for any help you can give.


The rest of the code is as follows:

This doesn't work:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stDocName As String
Dim stWhere As String
stWhere = "([EndDate]=#" & Me.txtEndDate & "#) "
stDocName = "BasicTime"
DoCmd.OpenReport stDocName, acPreview, , stWhere

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub


This code, which to me seems identical except for the names of the fields,
runs just fine:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stDocName As String
Dim stWhere As String
stWhere = "([StDate]=#" & Me.StDate & "#) “
stDocName = "BasicTime"
DoCmd.OpenReport stDocName, acPreview, , stWhere

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub
 
J

Jeff Boyce

It sounds like the second report might not have a data source connected.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Marshall Barton

The code looks fine. The stWhere strings are ok if you are
using USA date settings in Windows.

The Error# in the report would be expected if there are no
records that match the end date criteria, so I suggest that
you focus your attention on why there are no matching
records.
 

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