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

Select CASE using a combo box

100+
P: 139
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
Share this Question
Share on Google+
3 Replies


missinglinq
Expert 2.5K+
P: 3,532
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

100+
P: 139
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
Expert 2.5K+
P: 3,532
Glad we could help!

Linq ;0)>
Jan 25 '08 #4

Post your reply

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