Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rating: Thread Rating: 9 votes, 5.00 average. Display Modes
Old 01-14-2010, 11:37 AM   #1
stocmamu
Registered User
 
Join Date: Jan 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
stocmamu is on a distinguished road
Open form based on combo box selection

I am using Access 2007 and have a data entry form and on it is a combo box that I would like to be used to determine what form would be opened next after a button is pushed on the form. So the user makes a selection from the combo box, then, depending on what was selected, a new form will be opened after a button is pushed on the first form. If I use a macro, what is the specific language I should use in the "Where Condition" in the OpenForm action?

stocmamu is offline   Reply With Quote
Old 01-14-2010, 11:51 AM   #2
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,126
Thanks: 13
Thanked 4,078 Times in 4,013 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Open form based on combo box selection

The wherecondition does not determine which form to open, just which record(s) will be displayed on that form. If you want to open different forms, I'd use code. If you want to stick with a macro, you'd have to test the value of the combo in the Condition area.
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 01-14-2010, 12:09 PM   #3
stocmamu
Registered User
 
Join Date: Jan 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
stocmamu is on a distinguished road
Re: Open form based on combo box selection

I had a feeling I would need to use VBA. Anyone have the code to do this? Unfortuantely for me I am a VBA novice and if I cant write a macro for it I cant get it into the database.

Thanks,

stocmamu is offline   Reply With Quote
Old 01-14-2010, 12:19 PM   #4
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,126
Thanks: 13
Thanked 4,078 Times in 4,013 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Open form based on combo box selection

Like I said, you can do it with a macro, you just have to use a Condition. In code, this type of thing:

Code:
Dim strForm As String

If Me.ComboName = "A" Then
  strForm = "FormA"
ElseIF Me.ComboName = "B" Then
  strForm = "FormB"
Else
  strForm = "FormC"
End If

DoCmd.OpenForm strForm
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
The Following 2 Users Say Thank You to pbaldy For This Useful Post:
JMarcus (06-23-2016), oswee (07-23-2012)
Old 01-14-2010, 06:06 PM   #5
ntanh72
Registered User
 
Join Date: Nov 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
ntanh72 is on a distinguished road
Re: Open form based on combo box selection

if your combo data source come from a table, I suggested you add a field in that table that store "form name", so the task is very simple:

docmd.openform me.myformnamecombo ,.....
ntanh72 is offline   Reply With Quote
Old 07-23-2012, 11:16 PM   #6
oswee
Newly Registered User
 
Join Date: Jul 2012
Posts: 3
Thanks: 3
Thanked 0 Times in 0 Posts
oswee is on a distinguished road
Re: Open form based on combo box selection

Quote:
Originally Posted by pbaldy View Post
Like I said, you can do it with a macro, you just have to use a Condition. In code, this type of thing:

Code:
Dim strForm As String

If Me.ComboName = "A" Then
  strForm = "FormA"
ElseIF Me.ComboName = "B" Then
  strForm = "FormB"
Else
  strForm = "FormC"
End If

DoCmd.OpenForm strForm


How can I let form to open specific record like ="[customerID]=" & [customerID]? Also in this code. So, i need to open specific record, but depending on value in this record i must to open different forms. This sample code works fine for me, only one problem is what i don't know how to open specific record. I don't know a syntax's.
P.S. Sorry, i am new in this forum. And i am from Latvia.
oswee is offline   Reply With Quote
Old 07-23-2012, 11:24 PM   #7
John Big Booty
AWF VIP
 
John Big Booty's Avatar
 
Join Date: Aug 2005
Location: Planet 10, by way of the Eighth Dimension
Posts: 8,263
Thanks: 113
Thanked 1,012 Times in 865 Posts
John Big Booty is a jewel in the rough John Big Booty is a jewel in the rough John Big Booty is a jewel in the rough
Re: Open form based on combo box selection

The red highlighted portion is what you will need to add;
Code:
Dim strForm As String

If Me.ComboName = "A" Then
  strForm = "FormA"
ElseIF Me.ComboName = "B" Then
  strForm = "FormB"
Else
  strForm = "FormC"
End If

DoCmd.OpenForm strForm, , ,"customerID= " & Me.customerID
Note; that customerID must be a field that resides on your current form.

__________________
...but they're only monkey boys!!!
John Big Booty is offline   Reply With Quote
The Following 2 Users Say Thank You to John Big Booty For This Useful Post:
JMarcus (06-23-2016), oswee (07-23-2012)
Old 07-23-2012, 11:33 PM   #8
oswee
Newly Registered User
 
Join Date: Jul 2012
Posts: 3
Thanks: 3
Thanked 0 Times in 0 Posts
oswee is on a distinguished road
Re: Open form based on combo box selection

Tnx a LOT! It works! Finaly! Yee... When You will be in Riga - bear from me!
oswee is offline   Reply With Quote
Old 07-23-2012, 11:42 PM   #9
John Big Booty
AWF VIP
 
John Big Booty's Avatar
 
Join Date: Aug 2005
Location: Planet 10, by way of the Eighth Dimension
Posts: 8,263
Thanks: 113
Thanked 1,012 Times in 865 Posts
John Big Booty is a jewel in the rough John Big Booty is a jewel in the rough John Big Booty is a jewel in the rough
Re: Open form based on combo box selection

Should I ever visit Riga I will look forward to sharing a



but not a



__________________
...but they're only monkey boys!!!
John Big Booty is offline   Reply With Quote
Old 07-23-2012, 11:57 PM   #10
oswee
Newly Registered User
 
Join Date: Jul 2012
Posts: 3
Thanks: 3
Thanked 0 Times in 0 Posts
oswee is on a distinguished road
Re: Open form based on combo box selection

LOL..
Yee-yee... very funny..
My mistake.

oswee is offline   Reply With Quote
Reply

Tags
button , combo box , form

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box data / refreshing depending on another combo box selection hully333 Queries 2 05-16-2008 05:32 AM
How to reference a combo box on one form from another form. poporacer Forms 6 04-01-2008 01:44 PM
Print Form Based on Combo Selection? phn General 2 04-10-2006 11:11 PM
Open Relevant Form Based on 2 Combo Boxes? phn General 1 04-06-2006 07:46 AM
Code to open form based on value in text box LisaP Modules & VBA 1 08-02-2001 07:31 AM




All times are GMT -8. The time now is 09:24 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World