Code on OpenForm problem
Function MyMsgBoxRestore(Message As String, Title As String, ButtonZeroText As String, ButtonOneText As String, FocusVal As Integer) As Integer
On Error GoTo MyMsgBoxRestore_Err
' Initialize return value to -1 (for cancel)
' MyMsgBoxRestore = -1
MyMsgBoxRestore = 1
' --- Open form and set it up
' --- Note: A_DIALOG would've been handy but the form couldn't
' --- be set up until it was closed or hidden
DoCmd.OpenForm "MsgBoxFormRestore"
Forms![MsgBoxFormRestore].Caption = Title
Forms![MsgBoxFormRestore]![Message].Caption = Message
Forms![MsgBoxFormRestore]![Button0].Caption = ButtonZeroText
Forms![MsgBoxFormRestore]![Button1].Caption = ButtonOneText
' --- Set default button
Select Case FocusVal
Case 0
Forms![MsgBoxFormRestore]![Button0].SetFocus
Forms![MsgBoxFormRestore]![Button0].Default = True
Case 1
Forms![MsgBoxFormRestore]![Button1].SetFocus
Forms![MsgBoxFormRestore]![Button1].Default = True
Case 2
Forms![MsgBoxFormRestore]![Cancel].SetFocus
Forms![MsgBoxFormRestore]![Cancel].Default = True
End Select
' --- Wait for form to be closed or hidden
Do While IsLoaded("MsgBoxFormRestore")
If Forms![MsgBoxFormRestore].Visible = False Then
If Forms![MsgBoxFormRestore]![Check0] = True Then
MyMsgBoxRestore = 0
Exit Function
ElseIf Forms![MsgBoxFormRestore]![Check1] = True Then
MyMsgBoxRestore = 1
Exit Function
End If
End If
DoEvents
Loop
'User cancelled so simply exit
MyMsgBoxRestore_Exit:
Exit Function
MyMsgBoxRestore_Err:
MsgBox Error$
Resume MyMsgBoxRestore_Exit
End Function