473,586 Members | 2,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I open a form using a combo box in the switchboard?

4 New Member
Hi guys,
I'm fairly new to access, with the help of this site and google I've managed to find my way around (even dabbling with some VB too) but there's something that's got me stuck.
I've got my DB working great, it's got the standard switchboard generated via the switchboard manager. I've got a load of forms and reports on there so I'd like to use a combo box to open up my forms rather than the buttons. For example I've got five forms I'd like to open up in add mode (one combo box) and another five forms I'd like to open in edit mode (second combo box). I'm sure this can be done but I'm struggling to find anything out there that can help me out... any ideas?
Many thanks,
Matt
Jul 26 '07 #1
7 4762
Mattic
4 New Member
Noone got any ideas?
Jul 26 '07 #2
missinglinq
3,532 Recognized Expert Specialist
Setting the RowSource of a combobox to retrieve the names of all the forms in a database is easy, but opening some in one mode and some in others is a little bit more compicated.

Method A - Using 2 Comboboxes
You'd have to rename your forms, placing a a prefix before each name, i.e. edForm1 for a form you want to open in Edit mode and adForm2 for a form you want to open in Add mode. One combobox would retrieve all forms with the ed prefix and the other would retrieve all forms with the ad prefix. Then in the AfterUpdate event of the combobox the selected form would be opened in the appropriate mode.

Method B-Using 1 Combobox
The combobox would retrieve the names of all forms. In the AfterUpdate event of the combobox you would use a Select Case construct to tell Access which mode to open a particular form in.

There are some drawbacks to both methods. Method A requires that you stick to a strict naming convention in order that the correct forms are retrieved by the appropriate combobox. If you have forms in your database that you don't want retrieved by either combobox, you'd have to be sure not to name them with anything starting with either ed or ad. The SQL statement behind your comboboxes looks at the first two letters of the form's name in deciding whether or not to retrieve it. The advantage to this method is that if you later create new forms, you can include them in one or the other combobox by the simple virtue of the name you assign to them.

The drawback to Method B is that you would have to do the coding for the Select Case statement when you first set this up, and modify it each time you add a new form, to tell Access how to open the forms.

Think about which approach you'd prefer to use and let me know, and I'll post the relevant code for you..

Welcome to TheScripts!

Linq ;0)>
Jul 26 '07 #3
Mattic
4 New Member
Thanks Linq it's good to be here :)
Method A sounds like the best for me - thanks again!
Matt
Jul 27 '07 #4
missinglinq
3,532 Recognized Expert Specialist
From my previous post:
"You'd have to rename your forms, placing a prefix before each name, i.e. edForm1 for a form you want to open in Edit mode and adForm2 for a form you want to open in Add mode. One combobox would retrieve all forms with the ed prefix and the other would retrieve all forms with the ad prefix.

While this doesn’t involve a lot of code, it does involve a bit of setting up of of properties that can be daunting for a newbie, and so I’m going to give you step-by-step instructions on this.

Place two comboboxes on your form. When the Wizard comes up click on “Cancel”

For each combobox

Right click on the combobox
Click on Properties
Click on Other
Enter Names for Combobox (SelectFormsEdit and SelectFormsAdd respectively)
Click on Data
Set Row Source Type to Tables/Query
Set the Row Source by copying and pasting the SQL statements below

Row Source for Forms in Edit Mode

SELECT [MSysObjects].[Name] FROM MsysObjects WHERE (Left$([Name],2) = "ed") And ([MSysObjects].[Type])=-32768 ORDER BY [MSysObjects].[Name];

Row Source for Forms in Add Mode

SELECT [MSysObjects].[Name] FROM MsysObjects WHERE (Left$([Name],2) = "ad") And ([MSysObjects].[Type])=-32768 ORDER BY [MSysObjects].[Name];

*************** *************** *************** **********
Right click on the combobox
Click on Properties
Click on Events
Click to the right of the AfterUpdateProp erty box
Click on Code Builder
For the appropriate Comboboxes enter the code below

DoCmd.OpenForm SelectFormsAdd, , , , acFormAdd

DoCmd.OpenForm SelectFormsEdit , , , , acFormEdit

so that the code looks like this

Expand|Select|Wrap|Line Numbers
  1. Private Sub SelectFormsAdd_AfterUpdate()
  2.  DoCmd.OpenForm SelectFormsAdd, , , , acFormAdd
  3. End Sub
  4.  
Expand|Select|Wrap|Line Numbers
  1. Private Sub SelectFormsEdit_AfterUpdate()
  2.  DoCmd.OpenForm SelectFormsEdit, , , , acFormEdit
  3. End Sub
Good Luck!

Linq ;0)>
Jul 27 '07 #5
Mattic
4 New Member
Linq you star! It worked great thanks for your time :) I've now got a great looking switchboard!

The only thing I needed to was allow edits on the form itself (below) and it all worked great!

"The form that the wizard creates sets the "Allow Edits" property to "No." This setting effectively disallows any selection from combo boxes. All you need to do is open the form in Design View, go to the Properties list for the form itself, and change the Allow Edits property to "Yes." Save and close the form. You will now be able to make a selection in the combo box."
http://www.accessmvp.c om/JConrad/accessjunkie/switchboardfaq. html#combobox

Thanks again!
Jul 30 '07 #6
missinglinq
3,532 Recognized Expert Specialist
Didn't realize that! Most of us here don't use the Switchboard Manager, but rather create our own using a form. Forms are much more flexible! It makes sense, though, because in the normal scheme of things you wouldn't be editing records (or doing abything else to them) on a Switchboard. This behaviour is restricted to the Switchboard Wizard; the Form Wizard sets AllowEdits - AllowDeletions - AllowAdditions all to Yes.

Glad you got everything working! It was fun working on this for you!

Linq ;0)>
Jul 30 '07 #7
mb60
37 New Member
Sir
The code to open forms in combo box worked very nicely !
Interface of my database changed like a beautiful face
thank you
Jan 21 '10 #8

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

Similar topics

13
3213
by: Martin Dennett | last post by:
Hi I'm new to this group so go easy on me! I currently use a database that has had one constant niggle for a while and I was wondering if anybody can help sort it out. From an opening screen there is an option to search for a particular record. The search criteria is entered into a text box. A form is presented over the top of the opening...
4
9408
by: Terry | last post by:
I have created a Main Switchboard in Access 2000 and it has a button which opens a Form. I have set the form Properties Default View to Datasheet and this always opens in datasheet view. When I open the Form from the Main Switchboard it always opens in form view. Can this be changed so that it always opens in Datasheet View? Terry
1
1406
by: tdmailbox | last post by:
I am looking to set up a switchboard that doesnt have new forms open as pop open in new windows like they do as the default I am looking to make my own switchboard where I have the list of forms I can open on the left and a box on the right where they open into. Basicly I am trying to replicate the code that Peter's software uses to make...
2
4910
by: Miguel | last post by:
I have reviewed the many postings on this topic and understand the principle, but am not sure where in my case to apply trapping an error. I have created a form to supply parameters to a report. I click on the command button to open the report, the form opens as it should and the parameters are entered. Upon clicking on "OK," the underlying...
3
3835
by: Cagey | last post by:
What I'm trying for: If this selection or if click on selection (highlighted line choice/ which ever selection change) w/in query's combo dropdown list box (on Switchboard), then Open in Datasheet View, the specific underlying record's Row... showing all columns Or selected columns. For a specific row's record ONLY, Or for all Xs (same...
9
3330
by: mtgrizzly52 | last post by:
Hi all, I've looked for an answer for this in lots of books, online in several discussion groups and have not found the answer which I feel may be very simple. What I want to do is have a switchboard with several active buttons on it for entering new data, updating data, reports etc. The new data and report stuff is easy, but the update...
6
3527
by: Markus_989 | last post by:
I have a LOANS table that has a list of loan details for different borrowers. I have a main switchboard with a LOANSELECT combo box (that displays a list of borrower last names and loan numbers). I'd like to be able to have a user click on the say, RECEIVE PAYMENT button that will open the payments form. This form should open to the loan...
1
3635
by: Kevin Welch | last post by:
Looking for some expert help here. Caveat: I do not know SQL, and I've built a database basically by trial and error (unfortunately, I don't have much time to learn Access as I would want). My basic database form is for patients, and I store their info in the database and link to videos of surgery, etc. I made a switchboard, a few...
4
8922
by: Nour469 | last post by:
Hello, I need simple help! I have a form with a field (DrsName) which is a combo box that looks up values in another table (Drs List). When I come across a name that is not in the list, I need to open the form (Drs List) and add the name. for which I added a cute button. I am having 2 problems: 1) I cannot get the button to open the form in...
0
7911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7954
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.