If I just open the form from the form menu I don't get anything after I
choose the value of the reroute contact - once I press the button the
the
form closes and there is nothing there
:
What do you get if you:
- open the ParamForm
- select a value in RerouteContacts
- view the datasheet of your query
--
Duane Hookom
MS Access MVP
Here is what is in the SQL
SELECT [Reroutes Table].ID, [Reroutes Table].Date, [Reroutes
Table].[Reroute
Contacts], [Reroutes Table].[MCS Number], [Reroutes Table].[Count Of
Pieces],
[Reroutes Table].[1st Attempt Follow-up Date], [Reroutes Table].[2nd
Attempt
Follow-up Date], [Reroutes Table].[3rd Attempt Follow-up Date],
[Reroutes
Table].[Date Received Back]
FROM [Reroutes Table]
WHERE ((([Reroutes Table].[Reroute
Contacts])=[forms]![ParamForm]![RerouteContacts]) AND (([Reroutes
Table].[Date Received Back]) Is Null));
:
You need to open the query "Reroutes Not Received Back" in SQL view
and
copy
the sql and paste it into a reply.
--
Duane Hookom
MS Access MVP
message
I hope I am giving you the right information - I am new with
access
so
I'm
still learning all the terms.
The record source for the report that i am running is a Query:
Reroutes
Not
Received Back
After the button is clicked on the form the report is this shown
on
the
screen. Right now the information is blank. In the report
screen
under
the
properties I have on the ON OPEN the following code:
Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "ParamForm", , , , , acDialog
End Sub
On the ON CLOSE this is what I have:
Private Sub Report_Close()
DoCmd.Close acForm, "ParamForm"
End Sub
:
And then what happens? I assume you select a value in the combo
box
and
click a button. After the button is clicked, what happens? What
is
the
SQL
view of the Record Source of your report?
--
Duane Hookom
MS Access MVP
message
The form is closed when i run the report - when i click on the
report
to
open
it - the form then comes up with the combo box so that I can
choose
what
to
run the report on.
:
Again, is ParamForm closed when you first attempt to open
your
report?
Are
you using a command button to "close/hide" the ParamForm?
--
Duane Hookom
MS Access MVP
in
message
So, Is there something that I am doing wrong with what I
have
that
would
keep
the information from populating on the report?
:
Thanks for the example Ken. I know it can be done and
there
are
samples
like
this in MS stuff. It just hasn't made any sense to me to
use
it
in
any
apps
I have written.
--
Duane Hookom
MS Access MVP
"Ken Sheridan" <
[email protected]>
wrote
in
message
Duane:
I think it's a fairly common technique. I seem to
recall
seeing
an
example
from MS somewhere which loops in the Open event
procedure
until
the
form
is
opened, and the Solutions database includes a report
where
the
Open
event
rather crudely prompts the user to open a dialogue form.
Here's
an
example
of mine from a report's Open event procedure which
filters
a
report
based
on
an unrestricted query, but it could equally be done
where
the
query
references the control as a parameter. The dialogue
form
can
be
used
with
different reports as the report's name is passed to it:
Private Sub Report_Open(Cancel As Integer)
Const FORMNOTOPEN = 2450
Dim frm As Form
On Error Resume Next
Set frm = Forms!frmNameDlg
If Err = FORMNOTOPEN Then
' open dialogue form, passing report name to it
DoCmd.OpenForm "frmNameDlg", OpenArgs:=Me.Name
Cancel = True
Else
If Err <> 0 Then
' unknown error
MsgBox Err.Description, vbExclamation,
"Error"
Else
If Not IsNull(frm.txtLastName) Then
Me.Filter = "LastName= """ &
frm.txtLastName
&
""""
Me.FilterOn = True
Else
Me.FilterOn = False
End If
DoCmd.Close acForm, frm.Name
End If
End If
End Sub
The button on the dialogue form has the following as its
Click
event
procedure:
Private Sub cmdOpenReport_Click()
Const REPORTCANCELLED = 2501
On Error Resume Next
' open report whose name was passed to form
DoCmd.OpenReport Me.OpenArgs, acViewPreview
Select Case Err.Number
Case 0
' no error so do nothing
Case REPORTCANCELLED
' anticipated error so do nothing
Case Else
'unknown error so inform user
MsgBox Err.Description
End Select
End Sub
Ken Sheridan
Stafford, England
:
I'm not sure how many experienced developers use code
in
the
report
open
event to open a form for parameters. If you are using
that
method,
start
with the form closed.
I don't ever use that solution. I always have a form
open
where
the
user
can
enter criteria. Code will then open the report using
either a
"Where
Clause"
in the DoCmd.OpenReport as my sample code suggests or
having
a
reference
to
a control on a form hard-coded into the query.