Full Version: Combo Box selection to popup another form
UtterAccess Forums > Microsoft® Access > Access Forms
sa5389
Hi,
I am entering some textboxes in a form. Then there is a combobox . It has option "Yes" or "NO".
I want to open a new form if the option is "Yes" or else continue with the same form only.
Once it opens a new form, it should go in the "Add new record" mode (it is already referenced to a table) and then i need to enter some textboxes and then hit "done" so that it closes and returns to the main Form.
I trying this from the past 2-3 days and nothing is happening.
Can anyone please help me...!!!
egards,
Jack Cowley
In the On Click event of a command button:

If Me.NameOfComboBox = "Yes" Then
DoCmd.OpenForm "NameOfFormToOpenGoesHere", , , , acFormAdd
End If

This should do the trick....

hth,
Jack
dannyseager
Ok... the code you will need is something like
CODE
If me.YourComboBox = "Yes" then
    Docmd.openform "YourPopUpForm", , , , acFormAdd
else
end if

You can choose where to put this to suit your needs... it could be the on click event of a command button or the after update event of the combo box
dannyseager
pesky Jack sneeking in there frown.gif
How are you jack?
Jack Cowley
I am dandy Gov, but my code is wrong... I used acNewRec instead of acFormAdd. Got to change that...
ack
Jack Cowley
By the by... I think I am back in the home of my ancestors... Bucketing down but not nearly cold enough for snow...
dannyseager
Today it was -2C all day... but no rain frown.gif (I sent that over to you frown.gif )
I'm sure you managed to find a nice wine to watch the rain fall with frown.gif
sa5389
Hi Guys,
Thanks...that worked to open a new form and i was able to add a new record.
ut, when i saw it in Table, it was not populating in the field. It always showed me the 1st record and the same numbers.
Also, I need to go back to main form after entering the Texboxes in this form. It should go the next textbox there in the main form.
Odon't know much of Access or VB, I am assigned a tast and hence trying to learn. Please help.
Thanks,
Jack Cowley
Gov -
Sorry for taking so long to respond. It is my daughter's birthday today so I called her to wish her Happy Birthday. She would like to revisit the UK and I said that I know of a woman who can sing up a storm.. NOT TO WORRY as my daughter has her own connections... Now me...well, that is another story...
It is bucketing down and it is snowing in Boise, Idaho, where my daughter lives so you were successful in sending me the rain... And yes, I have a nice Pinot Noir to sip as the skys open up....
HRH
dannyseager
LOL!! I'll assume that's a nice wine frown.gif... If it's not made by Coca Cola I don't know it frown.gif
'd rather have rain than snow... but I'd rather have sun over them all.
If you send Your daughter over here Jack I'll send you the credit card bill... Jane can shop and shop and shop some more frown.gif
Jack Cowley
Be sure to check your table AFTER you close the form and if the form is bound to the table the data should be there.
do not understand what you mean by, "It should go the next textbox there in the main form." You will need to give us some specific details on what you are doing before we can give you an answer....
hth,
Jack And The Guy From The UK
Jack Cowley
Gov -
I have a feeling that my daughter and Jane would get on very well! They are both bright, articulate and enjoy a good time... My daughter is not much of a shopper so she and Jane will have to find other common ground...luckily for you!
HRH
sa5389
Hi,
To give more details:
When the combobox option is YES. It will go to a new form and there i enter some textboxes & return to main form after i hit "Update"
If option is NO then it has to go to next textbox in the main form.
crosschecked the table,,, It is not populating...
My code:
Private Sub cboEnggResources_AfterUpdate()
If Me.cboEnggResources = "Yes" Then
DoCmd.OpenForm "LCC Opportunities Table form - Satya2", , , , acFormAdd

End If

End Sub
Regards,
dannyseager
All the code you posted will do is open the 2nd form if the value is yes.... it wont actually post any data.
The data would be posted by the user once the form has been opened (unless there's something else you need to automate that you've not yet mentioned?)
dannyseager
Jack... I'm sure they would...
The doesn't have to shop much to run up the bill... it's all about WHERE they are shopping the would put the fear into me frown.gif
sa5389
Hi,
Ofound the error...my mistake. It works fine.
Can u please tell me how to make this work :--
When I hit "Update" the subform should update and unload and I should go to main form
If option is NO then it has to go to next textbox in the main form.
Regards,
dannyseager
To go to the next text box you can simple do
e.YourNextTetBox.setfocus
When you say subform do you mean the pop up form opened from the combo box?
sa5389
YES
dannyseager
Well the pop up form is bound to a table (You say it is in the first post) so the information should already be added...
You can close the form with
Docmd.close acform, me.name
You can also requery the original form if needed wih
forms!YourFirstForm.requery
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.