MSAccess VBA ORDER BY not working on dynamic recordsource
The below code sets the recordsource on my form. The ORDER BY is not working since all the form properties are blank. How do I get sort? Private Sub Form_Load() If Me.OpenArgs <> "" Then Me.AllowFilters = True Me.FilterOn = True Me.RecordSource = "QRY: BPRIL Data Entry By Order" Me.Filter = Me.OpenArgs Me.Requery ElseIf (Me.RecordSource <> "BPRIL Data Entry") Then Me.RecordSource = "BPRIL Data Entry" Me.Requery End If Me.OrderBy = "[Item #]" Me.OrderByOn = True End Sub
If you are setting the recordsource, why not take the opportunity to sort? Me.RecordSource = "SELECT Stuff FROM [BPRIL Data Entry] ORDER BY [Item #]" You should consider doing yourself a favour and getting rid of spaces in table names and field names, it will make life a lot easier.
Find function in Form Code Module
Docmd.Runsql Updating Select Max records by group
MS Access Can't Link to Encrypted Backend Database
Why is my LEFT JOIN an invalid operation (MS ACCESS 2003)
IIS7.5 MS Access Authentication
Getting a “Variable Not Defined” error when attempting to open a table in Access 2010
MS Access Report “per detail” formatting and accessing in VBA
Open form in access using criteria?
Temporarily change printer page size then revert back in Access 2007 using VBS
How to combine more than 2 Microsoft Access tables into one table?
Access mdb not giving correct result
MS Access Macro to change form to No data entry
setting control source property of a textbox of subform in its parent form in ms access?
I need to dynamically (and quickly) import part of the data in an Access table (a large one) into Excel
MS Access query does not append any rows as an append query, but does select rows as a select query
How can I stop my subform from autoscrolling when an item is being edited?