trying DoCmd.OpenReport to get multiple reports (1 Viewer)

noobaloop

New member
Local time
Yesterday, 17:37
Joined
Dec 10, 2017
Messages
6
Hello guys,

I have been looking for a solution to this all afternoon but i can't figure this out. My apologies but i am very new to access.

I want to open multiple reports at once in a print preview of different id's. So far the report does open but it will only open one id and not the range of id's.

I have 2 textboxes in my form, one with a value "from" and one with a value "to". These values refer to the id the report uses.

Here is my code:

Code:
Private Sub btnPrintRange_Click()

 DoCmd.OpenReport "rptInvoice", acViewPreview, , "[invoicenumber] BETWEEN " & Me.from & " AND " & Me.to

End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:37
Joined
Aug 30, 2003
Messages
36,124
I would expect that to open a single report with multiple invoice numbers based on the range. Are you sure there aren't multiple pages? There should be a page counter at the bottom.
 

noobaloop

New member
Local time
Yesterday, 17:37
Joined
Dec 10, 2017
Messages
6
I would expect that to open a single report with multiple invoice numbers based on the range. Are you sure there aren't multiple pages? There should be a page counter at the bottom.

Thank you for your reply.

I am very sure there aren't multiple pages. The counter on the bottom page "1" and the direction icons are greyed out indicated there is only 1 page. :(
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:37
Joined
Aug 30, 2003
Messages
36,124
And there are more than one invoice in the range entered? The field isn't text, is it? That would cause an alphabetical comparison. Can you attach the db here?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 01:37
Joined
Jul 9, 2003
Messages
16,273
I answered a very similar question recently and I posted the answer I gave to my website here:-


Generate Multiple Reports


Not sure if you intend emailing them, if you are, I would have a look at Gina Whipp's website, see link at the bottom of my post. Gina shows an excellent way of emailing the reports.
 

noobaloop

New member
Local time
Yesterday, 17:37
Joined
Dec 10, 2017
Messages
6
And there are more than one invoice in the range entered? The field isn't text, is it? That would cause an alphabetical comparison. Can you attach the db here?

Yes, there are is more than one invoice in the range, the numbers are correct. The field isn't text.

I tried to make a new form in my database and start over with trying to get this to work. When i run the code i don't get report anymore but a prompt asking me for an invoice id (which i would normally get when i would run the report)
 

Minty

AWF VIP
Local time
Today, 01:37
Joined
Jul 26, 2013
Messages
10,368
Have you tried using > 1234 And < 3214 instead of between?
What if you hard code some values into the reports underlying query and open it directly?
 

noobaloop

New member
Local time
Yesterday, 17:37
Joined
Dec 10, 2017
Messages
6
Have you tried using > 1234 And < 3214 instead of between?
What if you hard code some values into the reports underlying query and open it directly?

Excellent idea. I made a new form and tried to hardcode the values:

Code:
Private Sub btnPrintRange_Click()

 DoCmd.OpenReport "rptInvoice", acViewPreview, , "[invoicenumber] BETWEEN " & 201701150 & " AND " & 201701155

End Sub

but now nothing happens.

Both values are correct and exist.
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 20:37
Joined
Jan 23, 2006
Messages
15,379
I suggest you attach a copy of the database as zip file. (as PBaldy suggested in 4)

Please clarify the request DoCmd.OpenReport to get multiple reports

Are you trying to open multiple reports with one OpenReport command, or
are you trying to open a report with multiple records??
 

Minty

AWF VIP
Local time
Today, 01:37
Joined
Jul 26, 2013
Messages
10,368
Although they look like numbers I suspect they are text values.
Also try it like this
Code:
 DoCmd.OpenReport "rptInvoice", acViewPreview, , "[invoicenumber] > 201701150 AND [invoicenumber] < 201701155 "
 

noobaloop

New member
Local time
Yesterday, 17:37
Joined
Dec 10, 2017
Messages
6
I suggest you attach a copy of the database as zip file. (as PBaldy suggested in 4)

Please clarify the request DoCmd.OpenReport to get multiple reports

Are you trying to open multiple reports with one OpenReport command, or
are you trying to open a report with multiple records??

thanks for your reply. I can try adding the database but i should remove all data first, is this ok?

Clarification of the request:

- i am trying to open a report with multiple records. Basically i have a report for 1 invoice, this works ok. I want to make a button so i can print or save multiple reports (invoices) at once instead of having to print each invoice manually.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:37
Joined
Aug 30, 2003
Messages
36,124
You just leave enough data for a meaningful test. Certainly anything personal should be removed.
 

noobaloop

New member
Local time
Yesterday, 17:37
Joined
Dec 10, 2017
Messages
6
Although they look like numbers I suspect they are text values.
Also try it like this
Code:
 DoCmd.OpenReport "rptInvoice", acViewPreview, , "[invoicenumber] > 201701150 AND [invoicenumber] < 201701155 "

Hello, thank you very much for your input! I have tried this code, the report runs but it's empty ("#False").
 

Minty

AWF VIP
Local time
Today, 01:37
Joined
Jul 26, 2013
Messages
10,368
Ok final go without seeing your data :

Code:
DoCmd.OpenReport "rptInvoice", acViewPreview, , "[invoicenumber] In('201701150','201701155') "
 

Users who are viewing this thread

Top Bottom