Solved

me.orderby  returns an error enter parameter value

Posted on 2009-06-29
7
475 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

734 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