Solved

case select

Posted on 2004-07-31
4
288 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Is an IP address in a Range 22 70
SSRS expression Issue finding a string 10 49
Adding to a VBA? 6 46
Add a task in Outlook from access 11 32
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…
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.
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 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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now