Solved

me.orderby  returns an error enter parameter value

Posted on 2009-06-29
7
468 Views
Last Modified: 2013-11-28
I have a form that I need to change the order that the data is displayed inso I have replaced the "header Labels" with command buttons that I have the following code attached to and a hidden text box for each button that I track the current status of the sort order. When the code runs it errors at the me.orderby requesting me to input a value.

The data source for the form is the following query;
SELECT CredScan.EstNo, Q_ShpSup_QTEovd_w_ExstWSup.[1Job_no], Q_ShpSup_QTEovd_w_ExstWSup.OorC, CredScan.CreditorName, CredScan.CreditorInvNo, CredScan.DateTime, CredScan.ComputerName, Q_ShpSup_QTEovd_w_ExstWSup.InsCo
FROM CredScan INNER JOIN Q_ShpSup_QTEovd_w_ExstWSup ON CredScan.EstNo = Q_ShpSup_QTEovd_w_ExstWSup.Est_no1
ORDER BY CredScan.DateTime DESC;


Please give me a clue, as it is driving me up the wall, thank experts!
Private Sub cbVendorName_Click()

On Error GoTo Err_cbVendorName_Click

 

Dim strCurrSort As String

    If Not IsNull(Me.tbVendorName) Then

      strCurrSort = Me.tbVendorName

    Else

      Me.tbVendorName = "false"

      strCurrSort = Me.tb1VendName

    End If

      

    'Me.tb1VendName

    If strCurrSort = "True" Then

        Me.OrderBy = "tb1VendName DESC"

        Me.OrderByOn = True

        Me!tb1VendName.BackColor = 16777215 '4227200

        Me.tbVendorName = "false"

    Else

        ' Me.tb1VendName a test to verify that I have the syntax for the field name correct

        Me.OrderBy = "tb1VendName ASC"

        Me.OrderByOn = True

        Me.tbVendorName = "True"

        Me!tb1VendName.BackColor = 10998526

    End If

    ' refresh data

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

 

 

Exit_cbVendorName_Click:

    Exit Sub

 

Err_cbVendorName_Click:

    MsgBox Err.Description

    Resume Exit_cbVendorName_Click

    

End Sub

Open in new window

0
Comment
Question by:mdlp
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 13

Expert Comment

by:ioane
ID: 24742061
The value passed to the OrderBy function needs to be the name of one of your columns in the form.
i.e. Me.OrderBy = "CredScan.EstNo DESC"

If tblVendName is a label or variable containing the column name, then it should not be a string.
i.e. Me.OrderBy = tblVendName & " DESC"
0
 
LVL 61

Expert Comment

by:mbizup
ID: 24742064
Are you trying to use tb1VendName to specify the field that you are sorting on?

In other words, does the textbox contain the field name that should be used in the Order By clause?

If that is the case, the following line:

<Me.OrderBy = "tb1VendName DESC">

Should be

Me.OrderBy = me.tb1VendName & "  DESC"

0
 
LVL 75
ID: 24742065
What is the name of the parameter value it's asking for?  Typically this is because a field name is spelled wrong or a mistake in an expression.

mx
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 75
ID: 24742071
wow ... almost 3 simultaneous posts!
0
 

Author Comment

by:mdlp
ID: 24742473
Thank you and yes all at the same time, I just walked in and WHAM!
TamTrak;
Me.OrderBy = tblVendName & " DESC" still produces the same error

Mbizup;
tb1VendName is a text box on the form in the detail section ie a cloumn that is bound to the CredScan.CreditorName and the column that I want  to change the sort order of.
cbVendorName is a command button that is in the form header replacing the label.

DatabaseMX;  I thought the same thing and I have doubled checked the spelling before I sent this to you, I have been embarrased enough to have learned that lesson!  The rest of the code works and changes the back color if I do not input anything and click ok it finishes the if statement and returns me back to the button and I can continue this for ever.  I can manualy highlight the field and click the A-Z or the Z-A and it will sort the column.

Me.OrderBy = "tb1VendName DESC"  From my orig post returns - - an input box, with a header "enter parameter value"  and the description is "tb1VendName" with no "DESC".

Me.OrderBy = Me.tb1VendName & " DESC"  + Me.OrderBy = tb1VendName & " DESC" - produce the same thing  an input box, with a header "enter parameter value" and the description is the field value from the first record on the form ie Joes Crab Shack.

Thats about all I know, I hope this helps.
thanks


Sort-Error.jpg
0
 
LVL 13

Accepted Solution

by:
ioane earned 500 total points
ID: 24742523
Just use this:
Me.OrderBy = "CredScan.CreditorName DESC"
0
 

Author Closing Comment

by:mdlp
ID: 31598215
It is exactly what the doctor ordered!!!!!!!!!!
Thank you to all of the Experts, TamTrak I guess you were right on the path with the;
   Me.OrderBy = "CredScan.EstNo DESC", I f I had just changed it i could have saved us all a lot of work!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now