473,406 Members | 2,633 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,406 software developers and data experts.

if then else... not sure how to do it

Fspinelli
Good morning!

I have to develop the means for an end user to click on a drop down (or radio button) and produces a report based on all records with that drop down choice.

For example...I have a call table that has a drop down box with follow up dates (such as: 1 week, 2 weeks, 1 month, 6 months).

If the user click on the drop down "1 week"
Then preview a report of all calls needed to follow up in 1 week.
Else if it's 2 weeks,
Then preview a report of all calls needing a follow up marked 2 weeks...

etc and so on.

I'm no quiet sure how to code that in VB. Are there any resources here that I can read that explains this in laymen terms (or in my case, laywoman).

Thank you!

Kind regards,
Faith
Oct 26 '10 #1

✓ answered by mshmyob

I think a simple Select Case would work better than the nested if then else.

cheers,

9 1868
mshmyob
904 Expert 512MB
I think a simple Select Case would work better than the nested if then else.

cheers,
Oct 26 '10 #2
Thank you mshmyob!

Ok...where would I learn how to do make a select case?
Oct 26 '10 #3
mshmyob
904 Expert 512MB
Look online for "Select Case in Access".

Code might look something like this:

Assuming you have a combo box called cboDates and put this code in the Onclick event.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Select Case (Me.cboDates.Column(1))
  3.  
  4.     Case Is = "1 Week"
  5.         ' put code here
  6.  
  7.     Case Is = "2 Weeks"
  8.         ' put code here
  9.  
  10.     Case Is = "1 Month"
  11.         ' put code here
  12.  
  13.     Case Is = "6 Months"
  14.         ' put code here
  15.  
  16.     End Select
  17.  
  18.  
The case statement will only execute the first case that is true.

cheers,
Oct 26 '10 #4
Download from here developer refference. This link is for Office 2010 if you are using prior version you can find it on this site also. Folow instalation isntructions then pres F1 and search help. You will find all you need there.
Oct 26 '10 #5
Thank you, Kaloyan.
Oct 26 '10 #6
mshmyob,

What am I doing wrong?

I have a report based off of a query. I have a combo box that lists the various follow up times, and a command button with this code behind it:

Private Sub cmdFU_Click()
Select Case (Me.cboFU.Column(1))
Case Is = "1 Week"
DoCmd.OpenReport "follow_up_report"

Case Is = "2 Weeks"
DoCmd.OpenReport "follow_up_report"

Case Is = "1 Month"
DoCmd.OpenReport "follow_up_report"

Case Is = "6 Months"
DoCmd.OpenReport "follow_up_report"

End Select
Exit Sub
End Sub

I'm missing code, yes?
Oct 26 '10 #7
mshmyob
904 Expert 512MB
Hard for me to tell what you are doing wrong since you haven't told me what is happening.

But you should remove the Exit Sub line since that is not needed.

My example assumed you had 2 columns in your combo box - a hidden key column (primary key) and a descriptive column. I referenced the descriptive column (column(1)).

If your combo box only has a single column then change the column index from 1 to 0.

If that doesn't work please tell me what is happening and I can be more helpful.

cheers,
Oct 26 '10 #8
ADezii
8,834 Expert 8TB
Do you have a single Report, or multiple Reports based on each of the Intervals?
Oct 26 '10 #9
Maybe if I explain what I have to do first then direct me?

I have a table with a date field. it's a field the end user enters a date when he/she wants to follow up with a contact.

I need to make it so that when the end user starts up the switchboard that a message (or something printable is the preference) pops up and tells the end user that they need to follow up with (bla bla bla) because the query looked at the follow up date field.

I don't want to do a date parameter - i need the query to start up when the switchboard does and let the user know who they need to follow up with today.

Know what I mean? Does this help?

Thank you very much.
Faith
Nov 1 '10 #10

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

Similar topics

11
by: dmbkiwi | last post by:
I am new to this group, and relatively new to python programming, however, have encountered a problem I just cannot solve through reading the documentation, and searching this group on google. I...
33
by: Diez B. Roggisch | last post by:
Hi, today I rummaged through the language spec to see whats in the for ... else: for me. I was sort of disappointed to learn that the else clauses simply gets executed after the loop-body -...
27
by: Ron Adam | last post by:
There seems to be a fair amount of discussion concerning flow control enhancements lately. with, do and dowhile, case, etc... So here's my flow control suggestion. ;-) It occurred to me (a...
1
by: George | last post by:
Hi, I'm trying to run a select statement that takes includes an if/else clause. I need to select the 'tran_date' between.... if the current month is greater than 10 i.e. after OCT then the...
5
by: Henry Jordon | last post by:
hello I was wondering if someone could help me get a main going on this project I've completed the header file that the professor started us on but not really sure how to get the main going. If...
3
by: Amy | last post by:
Hi, I have 6 If Then Else statements I was supposed to write. I did so but I know that they have to be wrong because they all look the same. Could someone take a look at them and point me in the...
25
by: metaperl.etc | last post by:
A very old thread: http://groups.google.com/group/comp.lang.python/browse_frm/thread/2c5022e2b7f05525/1542d2041257c47e?lnk=gst&q=for+else&rnum=9#1542d2041257c47e discusses the optional "else:"...
22
by: John | last post by:
Hi Folks, I'm experimenting a little with creating a custom CEdit control so that I can decide on what the user is allowed to type into the control. I started off only allowing floating point...
5
by: PerlPhi | last post by:
hi,,, while ago i was wondering why do some programmers rarely uses the ternary operator. wherein it is less typing indeed. i believe in the classic virtue of Perl which is laziness. well let me show...
17
by: JRough | last post by:
I'm trying to get error proof code. I have this code which seems to work but now I look at it I think it should be elseif not else and I wonder why it works. It is in the block:...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
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
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...
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.