Table ordered by

D

Dexter

Hello!

I have to check if table in default view is ordered by some column. In table
properties window is property order by.
i can get table,bet i can't find property or method to get order by value.
Here is code how i get to table:
For Each tabula As dao.TableDef In ACS.TableDefs
If tabula.Name.Trim.ToUpper = sName.Trim.ToUpper Then
' ??
End If
Next

I hope you will help soon!

Dexter
 
K

Ken Sheridan

The following function will return the OrderBy property of the table whose
name is passed into it as its argument:

Public Function TableOrder(strTable As String) As String

On Error GoTo Err_Handler

Const PROPNOTFOUND = 3270
Const TABLENOTFOUND = 3265

Dim dbs As DAO.Database, tdf As DAO.TableDef

Set dbs = CurrentDb
Set tdf = dbs.TableDefs(strTable)

TableOrder = tdf.Properties("OrderBy")

Exit_Here:
Exit Function

Err_Handler:
Select Case Err.Number
Case PROPNOTFOUND
TableOrder = "Table " & strTable & " not ordered"
Case TABLENOTFOUND
TableOrder = "Table " & strTable & " not found"
Case Else
' unknown error
MsgBox Err.Description, vbExclamation, "Error"
End Select
Resume Exit_Here

End Function

Though I can't imagine why it is of any importance to know this as it’s not
advisable for a table to be viewed in raw datasheet view in an application.
Data should be accessible to users only via forms, which would be based on a
sorted query, or reports whose internal sorting mechanism should be used to
order the data. A table is a set and as such has no intrinsic order. The
order in which you see it in datasheet view is no more that that and of no
other significance. A table might be viewed in datasheet view while
debugging, in which case the OrderBy property might have some use, but
otherwise its irrelevant to a functioning application.

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top