Solved

case select

Posted on 2004-07-31
4
292 Views
Last Modified: 2010-05-02
I'm using a case select method to selecty reports.I have a message in forming to user to make a valid selection if none was made,the code works fine but the message box keeps poping up even though a valid selection was made here's the code.

 'cable/parts selection case 39'
 Select Case Me.Text39
 
 Case "cable Searchlocation"
 DoCmd.OpenForm "Please Wait", acNormal, "", "", , acNormal
 DoCmd.RepaintObject acForm, "Please Wait"
 stDocName = "Cable Report 2"
 DoCmd.OpenReport stDocName, acPreview
 'end cable selection'
 
 
 'parts selection'
 Case "parts search"
 DoCmd.OpenForm "Please Wait", acNormal, "", "", , acNormal
 DoCmd.RepaintObject acForm, "Please Wait"
 stDocName = "Parts report 2"
 DoCmd.OpenReport stDocName, acPreview
 'end heavy duty selection'


  Case Else
 
 MsgBox "Please make a valid selection,Thank you.", vbInformation
 
 
 
End Select
0
Comment
Question by:wwstudioinc
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11683559
IT may be worth adding a message box to each of your other cases, just to check that they are catching something.
0
 
LVL 8

Accepted Solution

by:
ampapa earned 125 total points
ID: 11683640
You migh try this? Have you tried breaking on each select case statement and stepping through the code?

 'cable/parts selection case 39'
 Select Case lcase(Me.Text39)
 
 Case is = "cable searchlocation"
 DoCmd.OpenForm "Please Wait", acNormal, "", "", , acNormal
 DoCmd.RepaintObject acForm, "Please Wait"
 stDocName = "Cable Report 2"
 DoCmd.OpenReport stDocName, acPreview
 'end cable selection'
 
 'parts selection'
 Case is = "parts search"
 DoCmd.OpenForm "Please Wait", acNormal, "", "", , acNormal
 DoCmd.RepaintObject acForm, "Please Wait"
 stDocName = "Parts report 2"
 DoCmd.OpenReport stDocName, acPreview
 'end heavy duty selection'

  Case Else
                MsgBox "Please make a valid selection,Thank you.", vbInformation
End Select

0
 
LVL 4

Expert Comment

by:SSSoftware
ID: 11683873
Suggestion - Reguardless of the other problem.

1) Whenever a user is allowed to enter a value, there is the problem of the "CASE" of the input.
2) Comparisons are made with case sensativity
3) Leading blanks can also cause a user problems and cause a invalid (missed)compare

Therefore
Always force the case to the correct value before comparison and always use a single case in the compare value and trim leading and trailing blanks for safety.

Note: This is only meaningfull as long as the case of the input does not make any difference

I suggest changeing your code to:


 Select Case UCASE(TRIM(Me.Text39))
 
 Case "CABLE SEARCHLOCATION"
   ...
   ...
   ...

 Case "PARTS SEARCH"
    ...
   ...
   ...

  Case Else
 
 MsgBox "Please make a valid selection,Thank you.", vbInformation
 
End Select

Good Luck,
Ed
0
 

Expert Comment

by:chdh
ID: 11685826
Insert a

 msgbox "/" & Me.Text39 & "/"

or

 debug.print "/" & Me.Text39 & "/"

before the "select case" statement to check the value of Me.Text39.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

774 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question