Hello,
I'm trying to build a custom msgbox function. In a module I have created a function that will open my custom form the user will use to make his choice. This choice is trapped through a public variable ("answered") Here it is:
Option Compare Database
Public answered As Integer
Public Function MakeQuestion(msgtxt As String) As Integer
DoCmd.OpenForm "frmAsk", , , , , , msgtxt
MakeQuestion = answered
End Function
*****
code in the frmAsk will allow user to make his choice:
Option Compare Database
Private Sub Comando1_Click()
answered = 1
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub
Private Sub Comando2_Click()
answered = 2
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub
Private Sub Comando3_Click()
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub
Private Sub Form_Load()
question.Caption = Me.OpenArgs
End Sub
I will then use the choice made by the user to take different different actions. TROUBLE is it wont work!
When I call this function on a procedure in another module (not class module, an ordinary module) the code doesn't wait but go straight to the end. Here is the code that calls my function:
dim myChoice as integer
myChoice = MakeQuestion("By continuing all of the data inserted in the form will be lost. Continute?")
Select Case myChoice
Case Is = 1
MsgBox "user answered yes"
Set collConsults = New Consults
DoCmd.OpenForm "frmConsulenza1", acNormal
Case Is = 2
MsgBox "ho risposto NO"
Exit Sub
End Select
MsgBox "end of the procedure"
What it happens is that as soon as the custom form ("frmAsk") called by the MakeQuestion function opens you get immediately MsgBox "end of the procedure". What is wrong???
Thanks
Rocco