Results 1 to 4 of 4
  1. #1
    roccoIT is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    2

    Custom MsgBox

    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

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Look at the options for OpenForm; look for acDialog. It will stop code execution until the form is closed or hidden.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    roccoIT is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    2
    T-H-A-N-K YOU!!
    You made it!
    I designed the form with
    popup:yes and
    modal:yes believing these settings where enough.

    But opening by passing acdialog seems to be solution...since it works! Although I still remain blind to why my previous settings wouldn't get the same result. Whatever!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Msgbox in a query with parameters
    By seb in forum Forms
    Replies: 7
    Last Post: 07-06-2010, 05:07 AM
  2. Yes No Cancel MsgBox
    By Rick West in forum Forms
    Replies: 5
    Last Post: 04-14-2010, 08:57 AM
  3. If Query result Is Null...MsgBox..Okl
    By Bruce in forum Forms
    Replies: 28
    Last Post: 03-10-2010, 10:57 AM
  4. Replies: 20
    Last Post: 02-17-2010, 12:12 PM
  5. Alterations to MsgBox command
    By Robert M in forum Programming
    Replies: 4
    Last Post: 06-30-2009, 02:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums