By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 1,905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

Opening a form from a combo box

P: 13
I have a combo box with a list in. I want to be able to click
on one of the values in this combo box, and a form will open. The difficult thing is that i want a different form to open for each value in the combo box. Preferably a macro. Any suggestions on how I might be able to achieve this?

Thanks
Sep 15 '08 #1
Share this Question
Share on Google+
2 Replies


missinglinq
Expert 2.5K+
P: 3,532
In all code, where your values in the combobox are

one, two, three, four

and the forms are

Form1, Form2, Form3, Form4

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourComboName_AfterUpdate()
  2.  Select Case YourComboName
  3.  
  4.    Case "one"
  5.     DoCmd.OpenForm "Form1"
  6.    Case "two"
  7.     DoCmd.OpenForm "Form2"
  8.    Case "three"
  9.     DoCmd.OpenForm "Form3"
  10.    Case "four"
  11.     DoCmd.OpenForm "Form4"
  12.  
  13.  End Select
  14. End Sub
Or if you already have macros made to open each form
Expand|Select|Wrap|Line Numbers
  1. Private Sub YourComboName_AfterUpdate()
  2.  Select Case YourComboName
  3.  
  4. Case "one"
  5.     DoCmd.RunMacro "OpenForm1Macro"
  6.    Case "two"
  7.     DoCmd.RunMacro "OpenForm2Macro"
  8.    Case "three"
  9.     DoCmd.RunMacro "OpenForm3Macro"
  10.    Case "four"
  11.     DoCmd.RunMacro "OpenForm4Macro"
  12.  
  13.  End Select
  14. End Sub
You will, of course, have to replace the combobox name, all combobox values and form names with your actual names.

Welcome to Bytes!

Linq ;0)>
Sep 15 '08 #2

P: 13
In all code, where your values in the combobox are

one, two, three, four

and the forms are

Form1, Form2, Form3, Form4

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourComboName_AfterUpdate()
  2.  Select Case YourComboName
  3.  
  4.    Case "one"
  5.     DoCmd.OpenForm "Form1"
  6.    Case "two"
  7.     DoCmd.OpenForm "Form2"
  8.    Case "three"
  9.     DoCmd.OpenForm "Form3"
  10.    Case "four"
  11.     DoCmd.OpenForm "Form4"
  12.  
  13.  End Select
  14. End Sub
Or if you already have macros made to open each form
Expand|Select|Wrap|Line Numbers
  1. Private Sub YourComboName_AfterUpdate()
  2.  Select Case YourComboName
  3.  
  4. Case "one"
  5.     DoCmd.RunMacro "OpenForm1Macro"
  6.    Case "two"
  7.     DoCmd.RunMacro "OpenForm2Macro"
  8.    Case "three"
  9.     DoCmd.RunMacro "OpenForm3Macro"
  10.    Case "four"
  11.     DoCmd.RunMacro "OpenForm4Macro"
  12.  
  13.  End Select
  14. End Sub
You will, of course, have to replace the combobox name, all combobox values and form names with your actual names.

Welcome to Bytes!

Linq ;0)>
Thanks mate, that worked great!

It's for my A-Level project, so this will impress them a little more.

Thanks for the great advice and welcoming
Sep 15 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.