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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT CASE Problems

Status
Not open for further replies.

dr00bie

Programmer
Feb 19, 2004
108
US
I am building an ADP for reporting and have run into some issues passing data from a Form to the report.

I have a combobox on my form named ddlSortBy and it contains 5 choices for the ORDER BY clause of the query, the combobox only has 1 column and that is a string. I am trying to detect which was submitted with a SELECT CASE statement, but it is not working correctly.

Code:
If (Forms!frmEventsByCatRegNoDate.ddlSortBy) <> "" Then
   Select Case SortBy
      Case "Date (New to Old)"
         SortBy = "Date DESC"
      Case "Date (Old to New)"
         SortBy = "Date ASC"
      Case "Register #"
         SortBy = "E.RegNo"
      Case "Aggressor Register #"
         SortBy = "E.AggressorRegNo"
      Case "Category"
         SortBy = "E.EventCatID"
   End Select
End If

If I set a breakpoint at the top of this and run the code, then it runs through without setting the SortBy variable. I have added this line of code,

Code:
MsgBox (Forms!frmEventsByCatRegNoDate.ddlSortBy)

so that I can see what ddlSortBy is passing. It looks correct, although I'm not sure if there is any whitespace before/after. I did check the ddlSortBy properties and don't see any spaces before/after.

What am I doing wrong?

Thanks,
Drew
 
From what you have said it sounds like
Select Case SortBy
should be
Select Case Forms!frmEventsByCatRegNoDate.ddlSortBy
 
I knew it was something simple that I was overlooking... just need to set SortBy to the Form element.

thanks,
Drew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top