[AccessD] Open Report from MainForm based on SubForm

Max Wanadoo max.wanadoo at gmail.com
Wed Oct 14 10:55:58 CDT 2009


DoCmd.OpenReport stDocName, acViewPreview, , "VehicleInspID=" &
"Forms![frm_VehicleInspection]![frm_VehicleInspectionSub].Form![VehicleI
nspID]


Max

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hollis, Virginia
Sent: 14 October 2009 16:39
To: accessd at databaseadvisors.com
Subject: [AccessD] Open Report from MainForm based on SubForm

Ok, I changed the control on the subform to txtVehicleInspID. But I am
not sure which one to change in the code. I tried it in all the
different VehicleInspID's changed them to txtVehicleInspID but I still
got an error. I wasn't sure which one was the name of the
txtVehicleInspID now.
 
DoCmd.OpenReport stDocName, acViewPreview, , "VehicleInspID=" &
"Forms![frm_VehicleInspection]![frm_VehicleInspectionSub].Form![VehicleI
nspID]=" & Me![VehicleInspID]
 
**********
You could make life easier by giving controls a different name from the
field they're bound to.  That would also reduce the incidence of this
kind of error.  Name your textbox txtVehicleInspID on the form and
change the code appropriately.  See whether that produces an error.  You
can get this kind of thing when Access can't figure out WHICH
VehicleInspID you're referring to.  The fact that it says  "Can't find
field VehicleInspID" says that it's looking for a field when it should
be looking for a control.  
 
Charlotte Foust
 
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
<http://databaseadvisors.com/mailman/listinfo/accessd> 
[mailto:accessd-bounces at databaseadvisors.com
<http://databaseadvisors.com/mailman/listinfo/accessd> ] On Behalf Of
Hollis,
Virginia
Sent: Wednesday, October 14, 2009 7:58 AM
To: accessd at databaseadvisors.com
<http://databaseadvisors.com/mailman/listinfo/accessd> 
Subject: Re: [AccessD] Open Report from MainForm based on SubForm
 
*         Form: frm_VehicleInspection
*         Subform: frm_VehicleInspectionSub
*         Report: rpt_VehicleInspection
*         Textbox on subform: Control source- VehicleInspID
*         Name of textbox on subform: VehicleInspID
*         Textbox on Report: Control source- VehicleInspID
*         Name of textbox on Report: VehicleInspID
 
Error: Microsoft Access can't find the field VehicleInspID referred to
in your expression.
 
 
stDocName = "rpt_VehicleInspection"
 
    Forms![frm_VehicleInspection]![frm_VehicleInspectionSub].SetFocus
    DoCmd.OpenReport stDocName, acViewPreview, , "VehicleInspID=" &
"Forms![frm_VehicleInspection]![frm_VehicleInspectionSub].Form![VehicleI
nspID]=" & Me![VehicleInspID]
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list