VBA Print Box Help Please

  • Thread starter Thread starter SG
  • Start date Start date
S

SG

I have tried both pieces of code below without success, and keep getting the
error MS Access has encountered a problem and needs to close message??


Does anyone have any further suggestions?

Thanks

S
 
first, do a compact and repair.

Next, while viewing code, do debug->compile.

Do you have any errors (in that code, or else where...get rid of them)

Next, try preving the reprot from the UI (can the reprot open, and fucntion
without problems?).

Next, try your code behind that buttion. You should "cast" the format into
usa format for dates...try:

Private Sub Command4_Click()

Dim ReportName as string
Dim strWhere as string
ReportName = "SalesReport1"

strWhere = "InvoiceDate Between #" & _
format(me.StartDate,"mm/dd/yyyy") & "#" & _
" and #" & format(me.EndDate,"mm/dd/yyyy") & "#"

DoCmd.OpenReport ReportName, acViewPreview, ,strWhere

End Sub

Private Sub Command4_Click()

Dim ReportName As String
Dim strWhere As String

ReportName = "SalesReport1"

strWhere = "InvoiceDate Between #" & _
Format(Me.StartDate, "mm/dd/yyyy") & "#" & _
" and #" & Format(Me.EndDate, "mm/dd/yyyy") & "#"

DoCmd.OpenReport ReportName, acViewPreview, , strWhere

End Sub

So, do a compile, and also try launching the report from the ms-access
UI..and see if that works. You should also be using the option explicit in
each code module to catch type-o errors.
 

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

Back
Top