Solved

case select

Posted on 2004-07-31
4
302 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
[X]
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
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

623 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