Connecting Tech Pros Worldwide Forums | Help | Site Map

Print Form to Report

Simone
Guest
 
Posts: n/a
#1: Nov 13 '05
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??

cvopicka@yahoo.com
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Print Form to Report


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.

Simone
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Print Form to Report


cvopicka@yahoo.com wrote in message news:<1108019414.473273.285000@o13g2000cwo.googleg roups.com>...[color=blue]
> 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.[/color]

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.
Ed Robichaud
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Print Form to Report


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" <seahorsecafe@gmail.com> wrote in message
news:e796a7bc.0502092248.32cdcca0@posting.google.c om...[color=blue]
> 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??[/color]


Closed Thread