Orderby syntax in VBA

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!
terpsichoreAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
terpsichoreConnect With a Mentor Author Commented:
found the problem - when i added square brackets around each term, it worked... strange...
0
 
NorieVBA ExpertCommented:
Is this an expression in the record source of the form?

iif(nz(salesowner_inits,"""")="""",1,0)
0
 
terpsichoreAuthor Commented:
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
 
terpsichoreAuthor Commented:
see note above. thank you.
0
All Courses

From novice to tech pro — start learning today.