Open Form Problem

marathonlady

Registered User.
Local time
Today, 01:14
Joined
Jul 10, 2002
Messages
120
I have a form I need opened with a message (using as a message box) when certain buttons are clicked on. When I first get into my program the form comes up as it should. Then I try it a second time and the form will not open.
Anyone have this problem?
 
I've had that problem before because I was using Macro buttons instead of VB code.

I just gave up using macros. The only thing I use now for macro is AutoExec. My guess is try using vb code to open forms it alot better and more effecient.

Here's the vb code to open forms

DoCmd.OpenForm ("Form Name")

Michael
 
Form open problem

I am using the Docmd.OpenForm "my form" code. Also using IsLoaded routine and Doevents.
 
Form open problem

I inheirited the code and the DoEvents was in there. I commented it out and the form doesn't come up properly the first time.
 
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
 

Users who are viewing this thread

Back
Top Bottom