Solved

Orderby syntax in VBA

Posted on 2014-02-07
4
328 Views
Last Modified: 2014-02-12
Dear experts:
Probably something simple, but the following line is giving me a syntax error when I call it:

Forms!main_form!sfContacts.Form.OrderBy = "status,iif(nz(salesowner_inits,"""")="""",1,0),salesowner_inits,leadtype,surname, forename,companyname,divisionname"

When I remove this bit, it works just fine: iif(nz(salesowner_inits,"""")="""",1,0)

I get an error each time i launch the form.

Any ideas?

Thanks!
0
Comment
Question by:terpsichore
  • 3
4 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 39842908
Is this an expression in the record source of the form?

iif(nz(salesowner_inits,"""")="""",1,0)
0
 

Author Comment

by:terpsichore
ID: 39842973
no, just salesowner_inits is a field in the recordsource

I've used iif clauses in creating an orderby string in VBA in the past, without any problem...
0
 

Accepted Solution

by:
terpsichore earned 0 total points
ID: 39843086
found the problem - when i added square brackets around each term, it worked... strange...
0
 

Author Closing Comment

by:terpsichore
ID: 39852813
see note above. thank you.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hit enter key to run macro 13 23
Launch app from Access custom ribbon 8 33
Question about DB Schema 27 56
ms access filter query with empty combobox 5 29
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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