• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

SQL Sort by through Access

I do have a Access form where I would like to implement an Click-Event where then my table on the SQL-2008-Server will be sorted and after I refresh my form an will then get the sorted results. Whats the easiest way to do that?
thx
Kongta
0
Kongta
Asked:
Kongta
  • 4
  • 2
2 Solutions
 
Jeffrey CoachmanMIS LiasonCommented:
<my table on the SQL-2008-Server will be sorted>
Sorted how...?

You can certainly do this by modifying the "Order By" property of the form

I don't see a need to go all the way back the the SQL server table and change the sort...
:-O

Private Sub YourButton_Click()
    Me.OrderBy = "YourField"
    Me.OrderByOn = True
    Me.Requery
End Sub


JeffCoachman
0
 
Rey Obrero (Capricorn1)Commented:
if your form is bound to the table, place this codes in the click event of a button

private sub cmdSort_click()

me.orderBy="[nameofField]"

me.orderbyon=true

end sub
0
 
Jeffrey CoachmanMIS LiasonCommented:

To be more syntactically correct:

Me.OrderBy = "YourField ASC"
Or
Me.OrderBy = "YourField DESC"
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
KongtaAuthor Commented:
ok, works, but strange as in my Access-book, it was said that I have to sort on SQL as it won't work on Access but didn't gave an example. May I ask one added as I filter right now on the Server as well and not in the form like

With cmd
    .ActiveConnection = c
    .CommandText = "sp_Modell_V1_tblStatistikChartTmp"
    .CommandType = adCmdStoredProc
    .CommandTimeout = 0
    .Parameters.Append .CreateParameter("@Auswahl", adVarChar, adParamInput, 100, "Index")
    .Parameters.Append .CreateParameter("@Auswahl_Detail", adVarChar, adParamInput, 100, Me.Index.Value)
    .Execute
End With
c.Close
Set c = Nothing
Set cmd = Nothing

Is there a more direct way on the form as well?
0
 
Jeffrey CoachmanMIS LiasonCommented:
Me.Filter="YourTextFiled=" & "'" & SomeTextValue & "'"
Me.FilterOn=True
Me.Requery

Or

Me.Filter="YourNumericFiled=" & SomeNumericValue
Me.FilterOn=True
Me.Requery
0
 
KongtaAuthor Commented:
many thx, I hope the split goes ok for both
rgds
Kongta
0
 
Jeffrey CoachmanMIS LiasonCommented:
<I would like to implement an Click-Event where then my table on the SQL-2008-Server will be sorted and after I refresh my form an will then get the sorted results>
Remember to always just state your "Ultimate Goal", (Sort/Filter a form), not the way you think it should be done...
;-)

...in case there is a more efficient technique...
;-)

Glad I could help...
;-)

JeffCoachman
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now