By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,476 Members | 1,553 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,476 IT Pros & Developers. It's quick & easy.

ODBC call failed in ms access 2007.

P: 99
Run-time error ‘3146’:
ODBC—call failed.
[Microsoft][ODBC SQL SERVER Driver][SQL Server]The ORDER BY position number 0 is out of range of the number of items in the select list.(#108)

The text above is the error that I am getting when I try to sort a column in my form.I am not able to understand what this error is supposed to mean.

Here is the code that I am using to sort the column,in case required.
Expand|Select|Wrap|Line Numbers
  1. Private Function ReOrder(vField As String)
  2.    Screen.MousePointer = MouseBusy
  3.    Me.OrderByOn = True
  4.    If Right(Me.OrderBy, 3) = "ESC" Then 'alleen laatste drie letters resolven
  5.       Me.OrderBy = vField & " ASC"
  6.    Else
  7.       Me.OrderBy = vField & " DESC"
  8.    End If
  9.    Me.Refresh 'requery
  10.    Screen.MousePointer = MouseNormal
  11. End Function
If I need to sort a column which has "No" as its control source and the header of the column is named lblPMNO
the I use this code,
Expand|Select|Wrap|Line Numbers
  1. Private Sub lblPMNO_Click()
  2. Reorder "No"
  3. End Sub
In case the recordsource of the form is expected:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCTROW tblMIMAIN.A_EQUIPDESCR AS
  2.  Equipment, tblMIMAIN.A_EQUIPNO AS [No], tblMIMAIN.A_ID,
  3.  tblMIMAIN.A_LOCATION AS Location, IIf(IsNull(tblMIMAIN!
  4. A_PROJECTID)," ","**13Mplan**") AS 13Months
  5. FROM tblMIMAIN
  6. WHERE (((tblMIMAIN.A_LOCATION)>IIf(GetAsset()
  7. ="**ALL**","a","ZZ") Or (tblMIMAIN.A_LOCATION)=GetAsset())
  8.  AND ((tblMIMAIN.A_SYSTEM)="STW"));
  9.  
Apr 17 '12 #1

✓ answered by Rabbit

No is a reserved key word. Change your column name.

Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,315
No is a reserved key word. Change your column name.
Apr 17 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.