[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Orderby syntax in VBA

Posted on 2014-02-07
4
Medium Priority
?
349 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 35

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

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…
Suggested Courses
Course of the Month19 days, 22 hours left to enroll

872 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