Open Report based on Checkbox on form

B

Brook

good day,

I want to open be able to check a box (requestforshipment is the name of
the checkbox) on my form for a specific number of records, then open my
report (rptshipmentrequest).

This is what I have but isn't working:

Private Sub Command37_Click()
On Error GoTo Err_Command37_Click

Dim stDocName As String

If Me.shipmentrequest = True Then
stDocName = "rptshipmentrequest"
DoCmd.OpenReport stDocName, acPreview

End If

Exit_Command37_Click:
Exit Sub

Err_Command37_Click:
MsgBox Err.Description
Resume Exit_Command37_Click

End Sub


Thanks,

Brook
 
S

SteveS

Brook said:
good day,

I want to open be able to check a box (requestforshipment is the name of
the checkbox) on my form for a specific number of records, then open my
report (rptshipmentrequest).

This is what I have but isn't working:

Private Sub Command37_Click()
On Error GoTo Err_Command37_Click

Dim stDocName As String

If Me.shipmentrequest = True Then
stDocName = "rptshipmentrequest"
DoCmd.OpenReport stDocName, acPreview

End If

Exit_Command37_Click:
Exit Sub

Err_Command37_Click:
MsgBox Err.Description
Resume Exit_Command37_Click

End Sub


Thanks,

Brook

Hi Brook,
This is what I have but isn't working:

How is it not working??? Are all records in the report? Or No records are in
the report??

I would guess that all records are being included in the report.
Try this:

Change the code for the button to:

Private Sub Command37_Click()
On Error GoTo Err_Command37_Click

Dim stDocName As String

stDocName = "rptshipmentrequest"
DoCmd.OpenReport stDocName, acPreview

Exit_Command37_Click:
Exit Sub


Next, change the Record Source *for the report* to select only the records
where shipmentrequest is True:

Open the query for the report and put "TRUE" (without the quotes) in the
criteria row for the [shipmentrequest] field.

Let me know what happens....

HTH
 
B

Brook

Steve,

Thanks for the response,

its not working b/c when I open my report, all records are showing and I
only want to show records in which shipmentrequest is "true".

I have the frmshipmentrequest and rptshipmentrequest based on the same qry
so that if I have "true" in the shipmentrequest criteria, I don' have any
records in my form.

Is this clear?

thanks,

Brook

SteveS said:
Brook said:
good day,

I want to open be able to check a box (requestforshipment is the name of
the checkbox) on my form for a specific number of records, then open my
report (rptshipmentrequest).

This is what I have but isn't working:

Private Sub Command37_Click()
On Error GoTo Err_Command37_Click

Dim stDocName As String

If Me.shipmentrequest = True Then
stDocName = "rptshipmentrequest"
DoCmd.OpenReport stDocName, acPreview

End If

Exit_Command37_Click:
Exit Sub

Err_Command37_Click:
MsgBox Err.Description
Resume Exit_Command37_Click

End Sub


Thanks,

Brook

Hi Brook,
This is what I have but isn't working:

How is it not working??? Are all records in the report? Or No records are in
the report??

I would guess that all records are being included in the report.
Try this:

Change the code for the button to:

Private Sub Command37_Click()
On Error GoTo Err_Command37_Click

Dim stDocName As String

stDocName = "rptshipmentrequest"
DoCmd.OpenReport stDocName, acPreview

Exit_Command37_Click:
Exit Sub


Next, change the Record Source *for the report* to select only the records
where shipmentrequest is True:

Open the query for the report and put "TRUE" (without the quotes) in the
criteria row for the [shipmentrequest] field.

Let me know what happens....

HTH
 
S

SteveS

Hi Brook,

No problem; just modify the code again and leave the query alone.


Change the Code for the button to:

'------------------------------------------
Private Sub Command37_Click()
On Error GoTo Err_Command37_Click

Dim stDocName As String
Dim strCriteria as String

stDocName = "rptshipmentrequest"
strCriteria = "[requestforshipment] = TRUE"


DoCmd.OpenReport stDocName, acPreview,,strCriteria


Exit_Command37_Click:
Exit Sub

Err_Command37_Click:
MsgBox Err.Description
Resume Exit_Command37_Click

End Sub
'------------------------------------------


If [requestforshipment] is not the name of the True/False FIELD in the
query, change "requestforshipment" in "strCriteria" to the correct field
name.

Let me know if it works.... ;)

HTH
 
S

SteveS

You're very welcome

--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Brook said:
Steve,

Thanks... that worked perfectly!

Brook

SteveS said:
Hi Brook,

No problem; just modify the code again and leave the query alone.


Change the Code for the button to:

'------------------------------------------
Private Sub Command37_Click()
On Error GoTo Err_Command37_Click

Dim stDocName As String
Dim strCriteria as String

stDocName = "rptshipmentrequest"
strCriteria = "[requestforshipment] = TRUE"


DoCmd.OpenReport stDocName, acPreview,,strCriteria


Exit_Command37_Click:
Exit Sub

Err_Command37_Click:
MsgBox Err.Description
Resume Exit_Command37_Click

End Sub
'------------------------------------------


If [requestforshipment] is not the name of the True/False FIELD in the
query, change "requestforshipment" in "strCriteria" to the correct field
name.

Let me know if it works.... ;)

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top