By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,657 Members | 1,045 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,657 IT Pros & Developers. It's quick & easy.

Print Form to Report

P: n/a
Hi,

I'm a DB newbie and I've been having issues trying to print the record
I am viewing in a form to a report. I have looked in groups all over
and they all say to try basically the same thing but I can't get it to
work.

This is the latest code I've tried:

Private Sub NewRepairPrintPreview_Click()

If Me.Dirty Then
Me.Dirty = False
End If

Dim strReportName As String
strReportName = "Print New Repair"
Dim strCriteria As String

If Me.NewRecord Then
MsgBox "There is no record to print..."
Else
strCriteria = "[Cust#] = " & Me.[Cust#]
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End If

End Sub

Using Access2000, the form is filtered to show only one record. When I
click the command button it comes up with the message box Enter
Parameter Value for Cust#, which I enter, but the report still shows
all of the records.

The report is currently sourced from the table, but when it was from a
query that didn't make any difference either.

Does anyone know what I'm doing wrong??
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
this is happening because it can't find the [cust#] so it is asking
for teh data. the Me.[Cust#] what is that. if it is a text box (like
a bound box to a column of the database) you might need to Cust#.Value
which will return the value of teh box. the only other thing i can
think of is the #. i will assume that is an abreviation but if it
isn't rename that so that there is no # sign.

that's all i can think of off the top of my head. hope this might help
some.

Nov 13 '05 #2

P: n/a
cv******@yahoo.com wrote in message news:<11**********************@o13g2000cwo.googleg roups.com>...
this is happening because it can't find the [cust#] so it is asking
for teh data. the Me.[Cust#] what is that. if it is a text box (like
a bound box to a column of the database) you might need to Cust#.Value
which will return the value of teh box. the only other thing i can
think of is the #. i will assume that is an abreviation but if it
isn't rename that so that there is no # sign.

that's all i can think of off the top of my head. hope this might help
some.


Hey I renamed cust# and tried adding .value but neither has seemed to
work, the box asking for the parameter still comes up. Adding the
..value just seems to have changed the custID on the report so that
they are all whatever number i entered as the parameter...

Also when I have tried giving more info about which field to use, ie.
Form![FormName]![Field] it tells me that it can't find the field.

This is so frustating, it's the last thing I need to do and I just
can't seem to get it.
Nov 13 '05 #3

P: n/a
Your code looks OK. You don't say if your form and report use the same
record source; if not, make sure that [cust#] is in both record sources.
Beyond that, you could ensure that both the form and report have bound
controls to [cust#] and that the controls are also named [cust#] (you can
make both controls invisible once you get it working). Also check the
report's group/sort property to correct any naming errors.
-Ed

"Simone" <se**********@gmail.com> wrote in message
news:e7**************************@posting.google.c om...
Hi,

I'm a DB newbie and I've been having issues trying to print the record
I am viewing in a form to a report. I have looked in groups all over
and they all say to try basically the same thing but I can't get it to
work.

This is the latest code I've tried:

Private Sub NewRepairPrintPreview_Click()

If Me.Dirty Then
Me.Dirty = False
End If

Dim strReportName As String
strReportName = "Print New Repair"
Dim strCriteria As String

If Me.NewRecord Then
MsgBox "There is no record to print..."
Else
strCriteria = "[Cust#] = " & Me.[Cust#]
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End If

End Sub

Using Access2000, the form is filtered to show only one record. When I
click the command button it comes up with the message box Enter
Parameter Value for Cust#, which I enter, but the report still shows
all of the records.

The report is currently sourced from the table, but when it was from a
query that didn't make any difference either.

Does anyone know what I'm doing wrong??

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.