=> Subforms

  • Thread starter Thread starter Rhonda Fischer
  • Start date Start date
R

Rhonda Fischer

Hello,

I would like to open my frmDeliveries Form which has
a subform of frmDeliverySub, with a recordsource
specifying a date range for Deliveries printed. I would
also like to display All deliveries without a date range,
without copying the two forms and rename them. I was
hoping to make use of the openarg and pass a value
to the parent form that would determine which subform
to display. Is there a way of doing this?

---------------------------------------------------------
Private Sub cmdLaunchFrmDeliveries_Click()
'Open parent form and OpenArg Value 1 to indicate
'subform with daterange query as recordsource
DoCmd.OpenForm "frmDeliveries", , , , , , 1
End Sub
---------------------------------------------------------

I'm a bit stuck here, I guess the Load event of both
parent and subform happen about the same time?

Any suggestion would be terrific

Thank you very much.
Rhonda
 
-----Original Message-----
Hello,

I would like to open my frmDeliveries Form which has
a subform of frmDeliverySub, with a recordsource
specifying a date range for Deliveries printed. I would
also like to display All deliveries without a date range,
without copying the two forms and rename them. I was
hoping to make use of the openarg and pass a value
to the parent form that would determine which subform
to display. Is there a way of doing this?

---------------------------------------------------------
Private Sub cmdLaunchFrmDeliveries_Click()
'Open parent form and OpenArg Value 1 to indicate
'subform with daterange query as recordsource
DoCmd.OpenForm "frmDeliveries", , , , , , 1
End Sub
---------------------------------------------------------

I'm a bit stuck here, I guess the Load event of both
parent and subform happen about the same time?

Any suggestion would be terrific

Thank you very much.
Rhonda
.
Hi Rhonda,

you could possibly consider using changing the subform
record source when you have a date range to consider.

To keep the sql simple I recommend using a saved query as
the recordsource of the subform.

Have the controls of the subform bound to the fields of
the query. But don't save the subform with a recordsource.
To improve load speed for the next step.

Have the openargs for the main form pass either 'all' or
the date range. Based on the openargs set the recordsource
for the subform to either the query or an sql. use the
following as an example...

If me.openargs="all" then
strSQL="qrySubform"
else
strSQL="select qrySubform.* from qrySubform where
([datefield] between " & me.openargs & ");"
end if

subformcontrol.form.recordsource=strSQL

Remember that no matter what the date format you normally
use, sql dates must be in american format. If required use
as an example...

strDate="#" & format(dtmDate,"m/d/yy") & "#"

Dates use the hash delimiter

Luck
Merry Christmas
Jonathan
 
Back
Top