Solved

case select

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA filters 2 70
SQL VB connection works in one PC and doesn't in another 15 73
VB6 - Scroll Mouse wheel on Picturebox 13 94
Dinamic report to Crosstab query 9 49
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

685 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