It's long - but here it is:
=======================================================
Option Compare Database
Option Explicit
Private Sub Combo61_AfterUpdate()
'** Place employee data from combo into fields as shown
Dim f As Form
Set f = Forms![Request for Visit Cancellation]
f![FullName] = f!Combo61.Column(2) + " " + f!Combo61.Column(1)
f![Social Security #] = f!Combo61.Column(4)
f![BirthDate] = f!Combo61.Column(6)
f![Birth City] = f!Combo61.Column(8)
f![Birth StateOrProvince] = f!Combo61.Column(9)
f![Birth PostalCode] = f!Combo61.Column(10)
f![Birth Country] = f!Combo61.Column(11)
End Sub
----------------------------------------
Private Sub FindAddress_AfterUpdate()
'**Place predefined address into fields as shown
Forms![Request for Visit Cancellation]![Address1] = Forms![Request for
Visit Cancellation]!FindAddress.Column(1)
Forms![Request for Visit Cancellation]![Address2] = Forms![Request for
Visit Cancellation]!FindAddress.Column(2)
Forms![Request for Visit Cancellation]![Address3] = Forms![Request for
Visit Cancellation]!FindAddress.Column(3)
Forms![Request for Visit Cancellation]![Address4] = Forms![Request for
Visit Cancellation]!FindAddress.Column(4)
End Sub
----------------------------------------
Sub PreviewHVL_Click()
On Error GoTo Err_PreviewHVL_Click
Dim stDocName As String
If IsNull([FullName]) Or IsNull([Address1]) Then
MsgBox "You must enter a Name and Address."
DoCmd.GoToControl "FindAddress"
GoTo Exit_PreviewHVL_Click
End If
stDocName = "Request for Visit Cancellation"
DoCmd.OpenReport stDocName, acPreview
Exit_PreviewHVL_Click:
Exit Sub
Err_PreviewHVL_Click:
MsgBox Err.Description
Resume Exit_PreviewHVL_Click
End Sub
----------------------------------------
Sub CloseForm_Click()
'** Close the form
On Error GoTo Err_CloseForm_Click
DoCmd.Close
DoCmd.Restore
Exit_CloseForm_Click:
Exit Sub
Err_CloseForm_Click:
MsgBox Err.Description
Resume Exit_CloseForm_Click
End Sub
================================================================
On the report's property sheet, the only calls are
On Open
=[DoCmd].[maximize]
On Close
=[DoCmd].[restore]
On No Data
Event Procedure
(as shown previously)
Dirk Goldgar said:
M Skabialka said:
I added the following code to the report:
Private Sub Report_Close()
Me.Visible = True
End Sub
Now I can close the report from the close button or the X in the
corner and the form stays open, but as soon as I open the report in
design mode, the form disappears or closes. All of the code on the
report validates entries on the form; or closes it when the close
button is selected. Nothing else tells it to become invisible or
close.
1) I have never used macros and there aren't any in this or any
database I have created.
2) There are no calls to any functions in this report's code. Here's
the entire report code module:
Option Compare Database
Option Explicit
Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data for this report. Cancelling report..."
Cancel = -1
End Sub
Private Sub Report_Close()
Me.Visible = True
[DoCmd].[Restore]
End Sub
Any other ideas about why my form closes when I go into design mode
on the report?
Thanks,
Mich
This is getting odder and odder. In the first place, this code you
added ...
Private Sub Report_Close()
Me.Visible = True
End Sub
... should have no effect whatever on the form. In the report's code
module, the "Me" keyword refers to the report, not the form. So I can't
understand why that code would make any difference to what's going on.
Yet you say it does. Very odd.
2) There are no calls to any functions in this report's code. Here's
That's not what I was referring to when I suggested "a call to a public
function (e.g, "=CloseForm('frmRptParms')") executed from one of the
report's events." This sort of call isn't made from the report's code
module, but from the properties of the report itself. If this
techniques is being used, then if you open the report's property sheet
in design view and look on the Event tab, on one of the event property
lines you'll see a function expression similar to the example I gave --
an equals sign followed by a function name, possibly with arguments
specified inside the parentheses. But if you look at the event
properties and see nothing but "[Event Procedure" (on the On Close and
On No Data lines), this isn't what's going on.
If there's nothing on the report, the only other thing I can think of is
something on the form, but it sure didn't sound like it. Would you care
to post the contents of the form's code module, too?
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)