?
Solved

SQL Sort by through Access

Posted on 2011-10-06
7
Medium Priority
?
307 Views
Last Modified: 2012-05-12
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
Comment
Question by:Kongta
  • 4
  • 2
7 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36926020
<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
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 600 total points
ID: 36926026
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
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36926036

To be more syntactically correct:

Me.OrderBy = "YourField ASC"
Or
Me.OrderBy = "YourField DESC"
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 

Author Comment

by:Kongta
ID: 36926155
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
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 1400 total points
ID: 36926265
Me.Filter="YourTextFiled=" & "'" & SomeTextValue & "'"
Me.FilterOn=True
Me.Requery

Or

Me.Filter="YourNumericFiled=" & SomeNumericValue
Me.FilterOn=True
Me.Requery
0
 

Author Closing Comment

by:Kongta
ID: 36926293
many thx, I hope the split goes ok for both
rgds
Kongta
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36926382
<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

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

864 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