RE: On Close
- From: Duane Hookom <duanehookom@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 19 Dec 2006 18:10:00 -0800
Your code seems to work for me. When I change the spelling of the form in my
code, I get the error 2450. What I can figure out is why you wouldn't copy
and paste your code into a reply. I would expect the If, Else, and End If to
be in proper capitalization.
--
Duane Hookom
Microsoft Access MVP
"benj" wrote:
Hi Duane! Thanks for the reply!.
The form is open as the preview icon is located on it, I checked that the
name of the form is correct (i even copy-pasted the name of the form to be
sure). The only code i have in previewing the report is:
Private Sub Command184_Click()
On Error GoTo Err_Command184_Click
Dim stDocName As String
Select Case Me.TabMAIN.Pages(Me.TabMAIN).Name
Case "NEC"
stDocName = "RF_nec1"
Case "HISTO"
stDocName = "RF_histo1"
Case "ELISA"
stDocName = "RF_elisa1"
End Select
DoCmd.OpenReport stDocName, acPreview
Exit_Command184_Click:
Exit Sub
Err_Command184_Click:
MsgBox Err.Description
Resume Exit_Command184_Click
End Sub
Then On Open event:
Private Sub Report_Open(Cancel As Integer)
if [Forms]![FM_MAIN]![Age] = "Yes" then
me.elisaSUB.SourceObject = "subreport1"
else
me.elisaSUB.SourceObject = "subreport2"
end if
exit sub
And I get the error 2450. Am using Access 2000 file format. Am not sure if
this is useful, the references are (in order) (1) VB for Application (2) MS
Access 11.0 Object Library (3) MS DAO 3.6 Object Library (4) MS ActiveX Data
Objects 2.1 Library and (5) OLE Automation.
"Duane Hookom" wrote:
If you get an error message that the form can't be found then I doubt the
form is open. You might want to confirm the name of the form and the control
on the form. Also, make sure you don't have any code the closes the form
about the time the report is being opened.
--
Duane Hookom
Microsoft Access MVP
"benj" wrote:
I tried placing the code in the On Open event:
Private Sub Report_Open(Cancel As Integer)
if [Forms]![FM_MAIN]![Age] = "Yes" then
me.elisaSUB.SourceObject = "subreport1"
else
me.elisaSUB.SourceObject = "subreport2"
end if
exit sub
But am getting the error 2450: can't find 'FM_MAIN' refered to in a VB code.
I actually seeked help regarding this but didnt get any reply (Changing
source object: Dec 10, 2006 and Source Object in Subreport: Dec 5, 2006).
The FM_MAIN form is open (where the preview icon is located)
Thanks Duane!
"Duane Hookom" wrote:
You can change the subreport source object in the On Open event of the
report. This can be done without opening in design view.
--
Duane Hookom
Microsoft Access MVP
"benj" wrote:
the preview command button will open the report in design view first, then it
will load the desired subreport then open it in preview mode. It makes
changes in the subreports Source Object so am being promted when closing. I
dont want to make changes or be prompted to. The shortened code is:
Private Sub Command184_Click()
On Error GoTo Err_Command184_Click
Dim stDocName As String
DoCmd.OpenReport "RF_elisa", acViewDesign
If Me.Age = "Yes" Then
[Reports]![RF_elisa1]![elisaSUB].SourceObject =
"RF_elisa_ext1"
Else: [Reports]![RF_elisa1]![elisaSUB].SourceObject =
"RF_elisa_ext2"
End If
stDocName = "RF_elisa1"
DoCmd.OpenReport stDocName, acPreview
Exit_Command184_Click:
Exit Sub
Err_Command184_Click:
MsgBox Err.Description
Resume Exit_Command184_Click
End Sub
Thanks!
"Duane Hookom" wrote:
Are you opening your report in design view? I haven't been normally been
prompted to save when I have made changes to properties in preview or print
modes.
--
Duane Hookom
Microsoft Access MVP
"benj" wrote:
Good day!
What code can i place "On Close" event (or in any event) that will close the
report without saving? I have created a report that has a changing
Subreports' SourceObject. Everytime i would close the report, save message
appears. I dont want the message to appear nor to save the report.
- Follow-Ups:
- RE: On Close
- From: benj
- RE: On Close
- References:
- RE: On Close
- From: benj
- RE: On Close
- From: Duane Hookom
- RE: On Close
- From: benj
- RE: On Close
- Prev by Date: Re: Stephen Lebans ReportToPDF, Please Help...
- Next by Date: RE: Report Examples
- Previous by thread: RE: On Close
- Next by thread: RE: On Close
- Index(es):