DoCmd.OpenReport (1 Viewer)

Blackelise

aka Andrew
Local time
Today, 00:54
Joined
Jun 13, 2012
Messages
35
Hi,

Please please could I have some help with this, it should be simple but it just does not work! :banghead: odd thing is that I though I had it working at one stage but now I'm notso sure!

I have a form with a Print button on it.

I have a report (that is surposed to print the information on the form).

Both the form and the report have a field called EstOrd_Number.

The idea is that I have an estimate shown within the form, I wish to print it off so I click the print button, this should load up the report with the same order number (EstOrd_Number) as that on the form - I am using preview rather than print for testing only.

I have used both a macro and coding both method fire up the report on the first record and not the correct EstOrd_Number. I have hunted around and tried diffferent ideas but to not avail.

the coding is:
Code:
Private Sub Command57_Click()
    'Calls the EstimatePrint for Review
    DoCmd.OpenReport "EstimatePrint", acViewPreview, , "EstOrd_Number = " & Me.EstOrd_Number

 Debug.Print EstOrd_Number & "  ..." & Me.EstOrd_Number
 
End Sub

Both EstOrd_Number & Me.EstOrd_Number = the the select record to print.

I'm lost - any ideas welcome.

Cheers
 

mdlueck

Sr. Application Developer
Local time
Yesterday, 19:54
Joined
Jun 23, 2011
Messages
2,631
Code:
    DoCmd.OpenReport "EstimatePrint", acViewPreview, , "EstOrd_Number = " & Me.EstOrd_Number

What datatype is the EstOrd_Number field?

The way you have it coded would be correct for a numeric datatype.

If it is a string datatype, then you need to encode double quotes around the Me.EstOrd_Number field, using Chr(34).
 

Blackelise

aka Andrew
Local time
Today, 00:54
Joined
Jun 13, 2012
Messages
35
What datatype is the EstOrd_Number field?

The way you have it coded would be correct for a numeric datatype.

If it is a string datatype, then you need to encode double quotes around the Me.EstOrd_Number field, using Chr(34).

its a numeric datatype. :confused:

Is there anything that I should check on the called report that I may have inadvertently changed?
 

mdlueck

Sr. Application Developer
Local time
Yesterday, 19:54
Joined
Jun 23, 2011
Messages
2,631
Is there anything that I should check on the called report that I may have inadvertently changed?

I would open the report programmatically, then can you bring the report back into edit mode in order to inspect the filter you have placed upon the report? Perhaps seeing the filter value in the UI will reveal something wrong with the rule.
 

vbaInet

AWF VIP
Local time
Today, 00:54
Joined
Jan 22, 2010
Messages
26,374
When you open the report by double-clicking do ALL the records appear?
And when you run the code what actually happens? Nothing appears?
 

Blackelise

aka Andrew
Local time
Today, 00:54
Joined
Jun 13, 2012
Messages
35
Resolved! thanks.

Some idiot had fixed the filter on the report to only show order no 1 what a muppet! Now where do I find the idiot......
 

Blackelise

aka Andrew
Local time
Today, 00:54
Joined
Jun 13, 2012
Messages
35
What a neat bit of code....and guess what it told me...? ;)
 

vbaInet

AWF VIP
Local time
Today, 00:54
Joined
Jan 22, 2010
Messages
26,374
I would hope 0, but knowing what some users are like 100/100 :) Just kidding! ;)
 

Users who are viewing this thread

Top Bottom