Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

case select

Posted on 2004-07-31
4
295 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Specify ip address in my connection string for sas 2 65
Windows 10 start screen issues 9 55
Add a task in Outlook from access 11 42
VB6 - Convert HH:MM into Decimal 8 62
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

838 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