Struggling a bit with this, I have a datasheet form which lists the ID and other info for each record. So far I have found some VBA code which will open each ID as a hyperli
A small disadvantage of acDialog
and .PopUp
is that the form opens as window outside the access main window. That's why I prefer to use just .Modal
if possible.
If you just want to block other open forms you can do a Me.Modal = True
even temporarily in the open event of your form.
The disadvantage of .Modal
is that it will not wait. DoCmd.OpenForm , , , , , acDialog
doesn't return until the form is closed. Such a synchronous call can be very useful sometimes.
To do an acDialog/PopUp
like call that stays inside the access main window you can use a little trick inside your form:
Private bFormOpen As Boolean
Public Sub ShowModal()
SetFocus ' Make the form visible
On Error GoTo ForcedClose
bFormOpen = True
Do While bFormOpen ' Wait until the form is closed
Sleep 50
DoEvents
Loop
ForcedClose:
Exit Sub
End Sub
Private Sub Form_Unload(Cancel As Integer)
bFormOpen = False
End Sub
You can than instantiate your form like this:
Dim f As New Form_Name
f.Modal = True
Call f.ShowModal
Set f = Nothing
DoCmd.OpenForm "Copy Of test", , , varWhereClause, ,acDialog
Though this will be pop-up and modal.