Need some help please! :) (1 Viewer)

Sweeto

Registered User.
Local time
Today, 20:35
Joined
Nov 5, 2002
Messages
10
I am trying to create a report that only prints the data of the current record from a form.

When I try and print it it prints a page with the labels but no data. What am I doing wrong?

could I email this to someone and take a look at it if you don't understand what I am asking?

Any help would be appriciated
Thanks
DOUG
 

BukHix

Registered User.
Local time
Today, 15:35
Joined
Feb 21, 2002
Messages
379
Sweeto,

Here is a sample that does what you want.

Dim strString as String
strString = Me.Field

DoCmd.OpenReport "ReportName", acViewPreview, , _
"[FieldOnReport] = '" & strString & "'"

The report will open and only the value that matches the Me.Field record will be shown.
 

Sweeto

Registered User.
Local time
Today, 20:35
Joined
Nov 5, 2002
Messages
10
does this code go in the report or the form?

thanks again
 

jjturner

Registered User.
Local time
Today, 20:35
Joined
Sep 1, 2002
Messages
386
Presumably, your 'Print Report' command button 'click' event on your form.

HTH,
John
 

Sweeto

Registered User.
Local time
Today, 20:35
Joined
Nov 5, 2002
Messages
10
BukHix said:
Sweeto,

Here is a sample that does what you want.

Dim strString as String
strString = Me.Field

DoCmd.OpenReport "ReportName", acViewPreview, , _
"[FieldOnReport] = '" & strString & "'"

The report will open and only the value that matches the Me.Field record will be shown.

in this what does the Me.Field mean?

In my database the report name is "closing" my form is named "closing" and the the field I want to print is"date"
 
Last edited:

jjturner

Registered User.
Local time
Today, 20:35
Joined
Sep 1, 2002
Messages
386
sweeto,

'Me' is the VBA reference to your open form (it references 'itself' by calling it 'Me' - lookup in Access Help).

If I'm reading BukHix correctly, 'Field' will be the name of your field that you wish to filter/run your report by - in this case it sounds like you need to substitute 'Date' where BukHix has referenced 'Field', so use:

Me.Date

AND

If it is a true date, you may have to use the '#' instead of single quotes in the expression, like so:

"[FieldOnReport] = #" & strString & "#"

HTH,
John
 

Shawny

Registered User.
Local time
Today, 20:35
Joined
Apr 15, 2000
Messages
64
Want the bonehead method?
This is how you make this happen with a macro.
I put this on a command button, on click.
Action: Run Command
Command: Save record
Action: OpenReport
Report Name: duh
View: Print
Where: [date]=[Forms]![closing]![date]
 

Sweeto

Registered User.
Local time
Today, 20:35
Joined
Nov 5, 2002
Messages
10
the bone head method is always good...


thanks for the advice, I'll let you know if I figure this out


:D :D :D :D
 

Sweeto

Registered User.
Local time
Today, 20:35
Joined
Nov 5, 2002
Messages
10
Thank You for all your advice I finaly got it to work properly
 

Users who are viewing this thread

Top Bottom