ok, I'll try that.
also how can i set the recordsource of a subreport thru VB?
this is what i have:
Private Sub Report_Open(Cancel As Integer)
Dim strID As Integer
Dim strSQLDesAddress As String
strID = [Forms]![frmMain_CommPkg]![txtID]
strSQLDesAddress = "SELECT tblDesignatedPremises.ID,
IIf(IsNull([DesignatedPremisesAddress2]),[DesignatedPremisesAddress1] & ', '
& [DesignatedPremisesCity] & ', ' & [DesignatedPremisesState] & ', ' &
[DesignatedPremisesZip],[DesignatedPremisesAddress1] & ', ' &
[DesignatedPremisesAddress2] & ', ' & [DesignatedPremisesCity] & ', ' &
[DesignatedPremisesState] & ', ' & [DesignatedPremisesZip]) AS
FullDesignatedAddress FROM tblDesignatedPremises WHERE
tblDesignatedPremises.ID = " & strID
Me![srtDesignatedPremises SubReport].Report.RecordSource = strSQLDesAddress
when i open the report i get a run time error(2455) You entered an
expression that has an invalid reference to the property Form/Report. The
property may not exist or may not apply to the object you specified.
There has to be a way to set the recordsource of a subreport thru VB but i
can't get the code right to reference the recordsource property.
In need of help!
TIA
Ted
Duane Hookom said:
Then use an unbound text box and set the control value with code like:
Me.txtPolNumber = [Forms]![frmMain_CommPkg]![txtPolNumber]
The code should be placed in the On Format event of the section containing
the control.
--
Duane Hookom
MS Access MVP
--
T Best said:
i don't think i can do that because the field is going to be equal to
either:
=[Forms]![frmMain_CommPkg]![txtPolNumber]
=[Forms]![frmMain_GLandLL]![txtPolNumber]
=[Forms]![frmMain_GL]![txtPolNumber]
=[Forms]![frmMain_LL]![txtPolNumber]
=[Forms]![frmMain_CommPkg]![txtPolNumber]
depending on which form is open.
i wanted to run code once the report is opened to check to see which form
is
open and then set the value of the field
"Rick B" <Anonymous> wrote in message
Why not just put an unbound filed on your report and place the reference
in
that unbound field...
=[Forms]![frmMain_CommPkg]![txtPolNumber]
or...
= "Policy Number: " & [Forms]![frmMain_CommPkg]![txtPolNumber]
--
Rick B
Hi all,
Is it possible to set a field in a report to a field on an open form
thru
code? For example...I have a report and i set the On Open Event
Procedure
as
follows:
Private Sub Report_Open(Cancel As Integer)
txtPolNumber = [Forms]![frmMain_CommPkg]![txtPolNumber]
End Sub
when i open the report i get the following error: Run-time error
'2448':
You
can't assign a value to this object.
if i set the value of txtPolNumber in design view to
"=[Forms]![frmMain_CommPkg]![txtPolNumber]" it works.
Any help would be very appreciated!
TIA
Ted