Modal pop up form

MikeLeBen

Still struggling
Local time
Today, 11:44
Joined
Feb 10, 2011
Messages
187
I would like some advice on how to build a modal pop up form in the following situation.

An event (entering an order with a cost that exceeds the availability of a certain customer) will open said form that is going to have 3 radio buttons to choose from.

I designed it so that the user cannot close it unless she chooses an option and then clicks on a button. By clicking on that button, a certain action will be carried out.
Firstly, I am not much certain as to how I can return the option picked by the user to the calling form so that the proper action is taken, (was thinking of a C-like return and a switch on calling form) plus I will take any advice you will feel like giving me.
 
Hi

How about using a global variable. I would need to be reset each time the model form is openned
 
I'm only just recently starting to use those, and so far I only have used the public type (which as far as I know only applies to the current module), should it be something along the line of:

Code:
Option Compare Database
Option Explicit

Global choice As Integer

in the main form?

Then in the pop up I can just use the choice variable without declaring it, right?
 
Hi

I think the variable should be declared in a module
 
Hi bob_fitz

Can you point me to somewhere I can learn how to use those?

Or is it just as simple as clicking on "insert module" and typing my code there? (Even though I wouldn't know how to reference it later). I'm still a beginner, so please be patient :)
 
Hi

Yes, click on "insert module" and then enter:

Global choice As Integer
 
You can use "openArgs" to pass limited data to the pop-up form.
Code:
    DoCmd.OpenForm "ACOE_Addition_PopUp", acNormal, , , acFormEdit, acDialog, Me.Form.Name
I like to pass the name of the calling form, since the pop-up form can be used by several calling forms.

For the pop-up form the values are set with the forms load event
Code:
        Me.Text1 = Forms(strCallingFormName).Controls("text631")
        Me.Text3 = Forms(strCallingFormName).Controls("text635")
        Me.Text11 = Forms(strCallingFormName).Controls("text633")
        Me.Check5 = Forms(strCallingFormName).Controls("check637")
        Me.Check7 = Forms(strCallingFormName).Controls("check639")
        Me.Check9 = Forms(strCallingFormName).Controls("check641")

To save data (from a check box) to the underlying form.
Code:
Private Sub Check9_Click()
    Forms(strCallingFormName).Controls("check641") = Me.Check9
End Sub

To Save text box changes:

Code:
Private Sub Text1_GotFocus()
    bolChanged = False 
End Sub
Private Sub Text1_Change()
    bolChanged = True
End Sub
Private Sub Text1_LostFocus()    
    If bolChanged Then Forms(strCallingFormName).Controls("text631") = Me.Text1
End Sub
 
Hi Steve R

I'm not sure how your post will help the OP with his/her original question?
....I am not much certain as to how I can return the option picked by the user to the calling form ....
 
I've created the module with the global variable and everything seems to work fine, except that the execution doesn't halt when the modal pop-up is opened and the lines that expect the value of choice to be one of the possible options are executed and skipped.
How do I make it wait until a choice is picked from the pop-up?
 
Hi

The line of code that opens the form needs to be somthing like:

DoCmd.OpenForm("YourFormName", , , , , acDialog)

The acDialog argument tell access to suspend the code that is running until the form that is being opened is closed.(If that makes sense:confused:)

Take a look in the VBA help file for "OpenForm Action" to read a better explanation.

If you have any further problem, please post back.
 

Users who are viewing this thread

Back
Top Bottom