Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case Not Working

Status
Not open for further replies.

pbrown2

Technical User
Jun 23, 2003
322
US
In the below code the select case is working for me.grpSortBy, to pick up the correct type of sorting. However, the select case for me.Criteria is not working to allow the selection of Active, Deleted, All items (cases 1, 2, 3 respectively)

Private Sub command3_Click()
Dim PlantSort As String
Dim strWhere As String
Dim strWhere1 As String

engall.Visible = False
engalll.Visible = False
bfs.Visible = False
bfsl.Visible = False
pfs.Visible = False
pfsl.Visible = False
tc.Visible = False
tcl.Visible = False
powertrain.Visible = False
powertrainl.Visible = False
EngineeringL.Visible = False
DoCmd.RunMacro "PlantCombo"
gstrTitle = "Composition / Status"
Select Case Me.Criteria
Case 1
strWhere1 = "[Deleted] = False"
Case 2
strWhere1 = "[Deleted] = True"
Case 3
strWhere1 = &quot;[Deleted] <=0&quot; ' nothing needed to get all records&quot;
End Select

Select Case Me.grpSortBy
Case 1
strWhere = &quot;[SortBy] = Y1Sum&quot;
PlantSort = &quot;[Plant] = 'Area1'&quot;
DoCmd.OpenReport &quot;General Info&quot;, acViewPreview, , PlantSort
Case 2
strWhere = &quot;[SortBy] = Project Classification&quot;
PlantSort = &quot;[Plant] = 'Area1'&quot;
DoCmd.OpenReport &quot;General Info&quot;, acViewPreview, , PlantSort
Case 3
PlantSort = &quot;[Plant]='Area1'&quot;
DoCmd.OpenReport &quot;General Info By Code&quot;, acViewPreview, , PlantSort
End Select

End Sub


Any suggestions?

Thank you for any and all help,

PBrown
 
As far as the Case statement not working, the only see that I can see is that Me.Criteria may not be numeric. You might try:
Code:
Select Case Val(Me.Criteria)
   Case 1
      strWhere1 = &quot;[Deleted] = False&quot;
   Case 2
      strWhere1 = &quot;[Deleted] = True&quot;
   Case 3
      strWhere1 = &quot;[Deleted] <=0&quot;
End Select
But I also not sure that this is a Case statement issue. In the two case statements, you are setting two parts of a where clause (strWhere1 and strWhere), but I don't see have either one of them have any influence over the Report. Where do you expect these two Where clauses to be put in play?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Hi

Could you clarify &quot;Not Working&quot;

Do none of the cases work?

Do you get any erroR messages?

In short what happens?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
The me.grpsortby works. The user can pick how they want to sort the report via case1 or case2 and the report will sort accordingly. Or if they wish they can group items and choose case3 which will run a different report.
However, it does not matter which &quot;Active&quot;, &quot;Deleted&quot; or &quot;All&quot;. It always gives them &quot;All&quot;. It seems that the me.criteria case is not working. As a note, I have made sure the case is named criteria, and Active is option1, Deleted is option2, and All is option3.

Thank you for any and all help,

PBrown
 
Hi

For the All option my inclination would be just to return where1 = &quot;&quot;

But as CajunCEnturiun already asked can we see the code that joins WHERE and WHERE1, into a single Where clause

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
If I take out the me.criteria cases the reports work just fine. (Basically nothing changes). Therefore I am sure CajunCEnturiun and KenReay are correct.

Now, how would I join these two where statements?
The only item that may cause problems (but then again I am new to select cases) is that case3 for grpsortby calls for a different report to be ran.



Thank you for any and all help,

PBrown
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top