var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
I am trying to open a form with a command button but I can not get the WHERE part of my code to work:
Dim strDocName As String
Dim strLinkCriteria As String
strDocName = "frmCompany"
strLinkCriteria = SELECT tblCompany.CompanyName, tblCompany.CompanyCustomer FROM tblCompany WHERE (((tblCompany.CompanyCustomer) = Yes))ORDER BY tblCompany.CompanyName
DoCmd.OpenForm strDocName, , , strLinkCriteria
Can anyone point out why I get error 3075 syntax error when I click the command button?
WHERE (((tblCompany.CompanyCustomer) = True))
Yes is not defined nor is it a recognized value.
WHERE (((tblCompany.CompanyCustomer) <> 0))
Have a nice day!
Tried both of your ideas and they both give me the same error meesage
Probably not the answer but why not design and save the query then design a form based on the query, you can add a button to open the form instead...
If that makes sense?
I will have a lot of forms to open and I want to do it in the most efficient way and not have lots of querys. Basically, I just want to know how to do it in code.
The wherecondition is a WHERE clause without the word "where", not the entire SQL string. Try
strLinkCriteria = "CompanyCustomer = True"
Some syntax variations:
Last edited by pbaldy; 02-25-10 at 17:45.
Reason: Add link for syntax
Thats works but how do I sort into alphabetical order?
ORDER BY tblCompany.CompanyName
Either base the form on a query that sorts the way you want or set the Order By property of the form. I'd go with the former if you always want it sorted the same way.
I have the orderby property on the form and want to sort by CompanyName. I type this into the property field but it does not sort it. What am I doing wrong here?
To be honest I always do it with the underlying query if it's always going to be the same. This should also work:
Private Sub Form_Load()
Me.OrderBy = "CompanyName"
Me.OrderByOn = True
No problem, hope it all works for you.