Full Version: Modal or modeless pop up
UtterAccess Forums > Microsoft® Access > Access Forms
flipper67
Does it matter which version of a pop up you use or is it just up to the programmer? I was thinking I would create a modeless pop-up form.
Shane
A modal form will not allow you to move the focus to some other form.
hane
flipper67
Is there a particular code you put in the event procedure for a form to open (pop up)?
freakazeud
Hi,
you would set the settings in the forms property window, or open the form in dialog mode (which sets these settings at runtime). E.g.:

DoCmd.OpenForm "YourForm",,,,,acDialog

HTH
Good luck
flipper67
I think I understand part of what you said. I need this form to open if the user answers a question on another form and they choose the answer "No".
freakazeud
So you have some code which produces a msgbox with a yes/no selection, right?
So just put the code I gave you in the no option e.g.:
Select Case MsgBox("Some message here!", vbYesNo Or vbExclamation Or vbDefaultButton1, Application.Name)
Case vbYes
'do nothing I guess
Case vbNo
DoCmd.OpenForm "YourFormName",,,,,acDialog
End Select
HTH
Good luck
flipper67
No, I don't have any code yet. I just made the forms.
freakazeud
So what "no" answer are the users pressing?
HTH
Good luck
flipper67
I have a check box. So I guess that won't work will it. Since the default must be no on a check box.
freakazeud
So you want a checkbox which is set to TRUE by default? And if the user does some action and did not change it to FALSE, then you want the pop up form to open?
HTH
Good luck
flipper67
Oh, I can do that. Leave it a check box and then set the properties to true=yes/false=no or something?
freakazeud
Sure you can do whatever you want.
To set the value of a checkbox in code use:
e.YourCheckBoxName = False/True
HTH
Good luck
flipper67
I am very new to code...I brought up the properties box for the checkbox and do I type that in the expression builider for "default value"?
freakazeud
No...the default value can only be a default value.
Maybe you need to explain a little more what it really is you are tring to do here in a general form. You are jumping from pop up forms to checkboxes and answers to default values...!
I'm not really sure anymore what it actually is you are trying to achieve.
HTH
Good luck
flipper67
I have a form that asks the user if the applicant is the homeowner or not. If they aren't, they I have another form for them to fill out for the landlord info. (Since they will be a tenant, if they aren't the homeowner). If they say "no" to the homeowner question, I want that form called Landlords to automatically pop up.
freakazeud
Ok...so you determine if the user is a homeowner or not with a checkbox selection by the user, right?
So on the after update event of the checkbox you can use code which determines its state and based on that opens the other form for more info e.g.:

If Me.YourCheckbox = True Then
DoCmd.OpenForm "YourFormName" ,,,,,acDialog
End If

HTH
Good luck
flipper67
Ok. I think I better remove the checkbox and put in a combo box or something that says yes and no and not have a default on it. Then if they click on "NO", it will read the code. Otherwise, with a ckbox, since it is always unchecked, it almost is like have it in default no, but it doesn't get updated or something. If I change the box to a combo box, will it still be the same code as above? Or do I replace the code of True with the word "No", or something?
freakazeud
Yes you would just need to reference your combobox and the value you want, in your case "no".
HTH
Good luck
flipper67
Thank you. End of my work day. Will tackle that Monday morning!
freakazeud
You're welcome.
Good luck and have a good weekend!
flipper67
I am finally trying to tackle this code to have a pop up form. Where would I put this:
o set the value of a checkbox in code use:
Me.YourCheckBoxName = False/True
______________
I have made my yes/no field a combo box with no default value. I want it to be that if the user selects "no" as the answer to the homeowner question, that the Landlord form will pop up. So where do I type: Me.YourCheckBoxName = False/True
freakazeud
Can you refresh my memory as to what you are exactly doing?
flipper67
Yes. i have a main form that asks the user if the applicant is the Homeowner or not. IF they answer no, then we have to fill out Landlord information on the house. So, if they answer no, I want the frmLandlord to open up automatically for them to fill in the fields. (I also would like it to close when finished so the user can go back to the main form.
freakazeud
Ok, so on the afterupdate event of your checkbox use:
If Me.YourCheckbo = True Then
DoCmd.OpenForm "YourPopUpForm"
End If
Then put a button on the pop up form which closes the form e.g.:
DoCmd.Close acForm, Me.Name
HTH
Good luck
flipper67
I am getting an error. This is the exact way I put it in the After Update. Did I type it right? also, all I did was put it on that line in after event. Should of I went into Code builder, and if so, where in ther would I type that code?
If Me.cboHomeowner = True Then
DoCmd.OpenForm "frmLandlords"
End If
cew657
I would use a combo box with HOMEOWNER or LANDLORD as an option. Based on what the applicant chooses then open the appropriate form with code on the after update event of the combo box. This would be the simpliest way to go.

Below is the code you could use:

CODE

Select Case Me![cboHomeowner]
    Case "HOMEOWNER"
        DoCmd.OpenForm "the name of your form for the homeowner",acNormal
    Case "LANDLORD"
        DoCmd.OpenForm "frmLandlord",acNormal
End Select


Oused a Select Case statement in case you may need to add more items to the combo box and it makes the code easier to read.

I don't think there is a way to close the pop up form automatically in this situation. How would the form know when the applicant was done filling out the information. You will probably have to give the applicant a close form button.

You replied just as I submitted my reply, so I included the name of your combo box in my code.

HTH

Chad
flipper67
Ok, well, actually it would be homeowner or tenant. Perhaps I could just have homeowner as default and then if they were a tenant, the user coudl change the applicant to tenant. And if that happens, the landlord form would pop up. Would I do the code the same as you typed, but just use the the word tenant instead of landlord for case? I still do not understand where to type the code either...
freakazeud
Yes you have to use the code builder...you can NOT just put it into the event line of the property window...select [event procedure] in the after update event then press the "..." next to it, this will open the VBA window with the preformatted after update event...put your code between the beginning and end of the sub. Close and retry!
HTH
Good luck
flipper67
Oh, I see. Right where the cursor takes me!
freakazeud
yes!
good luck
flipper67
Except I changed it from yes and no to homeowner and tenant. So I need it to open if they choose tenant. Same code? (cuz it didn't work...)
flipper67
Hey, I got it to work with a little help form the other poster in this thread an your help! Thanks!
freakazeud
So instead of having a checkbox you are now using a combobox?
Then it would be:
If Me.YourCombo = "homeowner" Then
'do something
ElseIf Me.YourCombo = "tenant" Then
'do something else
End If
This would assume that these values are in the bound column...if not then you need to specify the appropriate column of the combo which holds these values.
HTH
Good luck
flipper67
(I don't need to do anything if they choose homeowner. They just move on to the next field. Only if they choose Tenant, do we go to another form.) I ended up using this code, is it alright:
Select Case Me![cboHomeowner]
Case "Tenant"
DoCmd.OpenForm "frmLandlords", acNormal
End Select
freakazeud
I wouldn't use a case statement for this, but that's your choice.
Good luck
flipper67
How about:
If Me.YourCombo = "tenant" Then
"open frmLandlords"
End If
freakazeud
Yes I would use that, but make sure you get the openform method code correct:
oCmd.OpenForm "frmLandlords"
HTH
Good luck
flipper67
It worked! Thanks!
freakazeud
You're welcome.
Good luck on future projects!
flipper67
I noticed that when this form pops up, that the ApplicationId is not populating in frmLandlords. DB is attached if you want to look. Go to frmApplication and where it asks if the applicant is an owner or tenant, click on tenant. If will pop open that box, but not populate the ApplicationID. Any suggestions?
cew657
In the after update event of the combo box paste the following code:
CODE
  
If Me.cboHomeowner = "tenant" Then
     DoCmd.OpenForm "frmLandlords"
     [color="red"]Forms![frmLandlords]![ApplicationID] = Forms![frmApplication]![ApplicationID]  [/color]
End If

I just used the code that already existed for your combo box but what I added is in red. It basically takes the application id from your application screen and places on your land lord form.
HTH
Chad
flipper67
Awesome! It worked. You guys are the best!! Thanks so much.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.