473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Select CASE using a combo box

139 100+
Hi there,

I've not used Select Case statements, and as MS Access help is as much use as a chocolate teapot I thought I'd post my query here.

I have a combo box showing Task Summaries. When a particular one is selected I want Access to create a message box that a new tab is visible.

I can create the msgbox and show the tab, but how do I link it to the change in the combo option? Is a select ase statement on the AfterUpdate procedure the best - and if so, how do I create one?

Thanks!
Neil
Jan 25 '08 #1
3 29222
missinglinq
3,532 Expert 2GB
Select Case is an excellent choice if there are going to be a large number of possibilities, as it clearly sets out each possibility and what action is to be taken. If there will only be a couple of possibilities, most people would simply use the If...Then construct. Here's an example of each for your situation, where Target Task is the selection you want to carry out actions for:.

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourComboBox_AfterUpdate()
  2.  If Me.YourComboBox = "Target Task" Then
  3.   'Make new tab visible
  4.   MsgBox "New Tab is Visible"
  5.  End If
  6. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub YourComboBox_AfterUpdate()
  2.  
  3.  Select Case YourComboBox
  4.   Case "Target Task"
  5.    'Make new tab visible
  6.    MsgBox "New Tab is Visible"
  7.  
  8.   Case "Another Task"
  9.    'Do something else here
  10.  
  11.   Case Else
  12.     'Do something here when none of the above cases are valid
  13.  
  14.  End Select
  15.  
  16. End Sub
  17.  
Linq ;0)>
Jan 25 '08 #2
ndeeley
139 100+
Select Case is an excellent choice if there are going to be a large number of possibilities, as it clearly sets out each possibility and what action is to be taken. If there will only be a couple of possibilities, most people would simply use the If...Then construct. Here's an example of each for your situation, where Target Task is the selection you want to carry out actions for:.

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourComboBox_AfterUpdate()
  2.  If Me.YourComboBox = "Target Task" Then
  3.   'Make new tab visible
  4.   MsgBox "New Tab is Visible"
  5.  End If
  6. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub YourComboBox_AfterUpdate()
  2.  
  3.  Select Case YourComboBox
  4.   Case "Target Task"
  5.    'Make new tab visible
  6.    MsgBox "New Tab is Visible"
  7.  
  8.   Case "Another Task"
  9.    'Do something else here
  10.  
  11.   Case Else
  12.     'Do something here when none of the above cases are valid
  13.  
  14.  End Select
  15.  
  16. End Sub
  17.  
Linq ;0)>

Linq,

Fantastic - as ever!

Cheers
Neil
Jan 25 '08 #3
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Jan 25 '08 #4

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

Similar topics

0
by: David Engle | last post by:
I have created a form with 2 combo boxes. The purpose of the form is to export CR9 reports to selected types of formats (rpt, doc,xls, etc) and choose the destination for the report (mail, file,...
2
by: JMCN | last post by:
hello i have your basic select case question. i created a combo box and save it as a query. so whenever the user selects the value and clicks the export button, the select case should then export...
3
by: Paul | last post by:
I have some option boxes and combo boxes that looks up values on a separate table (i.e. campus table with campusID & campus name fields) When I choose a selection from the combo box, it puts the...
1
by: Cillies | last post by:
Does any one know if it is possible to search a database by using combo boxes from a form. I have a form which includes comboboxes. I want to know If I can use these combo boxes to search, i.e....
4
by: troy_lee | last post by:
I have a form that acts a filter. All of the filtering objects are in the header and the results are displayed in a continuous form in the detail section. In the header, I have a text box...
2
by: csolomon | last post by:
Hello: I am creating a form that will calculate a value based on the value selected from a case statement in a function. The function I created is called GetYield and accepts 3 arguments. I...
44
by: Desitech | last post by:
I am very new at this and trying to learn. I have built a database and on my main form, I have a combo box titled cbodocumenttype, a text box for user input entitled txtuserinput, and a command...
11
by: WannabePrgmr | last post by:
In access 2003, on a simple form, I am trying to base the recordsource of a combobox on two other combobox's data. Here is the code I've tried and it did not work (except for the PN Cross/Info). ...
43
by: Mac rod | last post by:
Hi everyone, could you please help me. i have a combo box that have the values "1st month", "2nd month" etc, a text box to put details such as weight, length and ccirc. what i want to do is when a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.