This is tricky..
I have a Form that produces a report. The first control is a combobox vith a list of names. I have also made it possible to choose "all" in the list.
The second control is for getting orders with date "from and "To".
The third is complicating things for me.
I would like a similar "From" - "To" fields as the date only with oredernumber instead, but I cant get it to work.
If I choose one name from the list it works, but if I choose not to enter ordernumber from/to I get nothing. I need help with the code that will return results even if the ordernumber-fields are left blank.
The second problem is that if I choose "All" and enter date and ordernumber it returns all ordernumbers, and not just those within the range that I entered..
The code that i use is:
WHERE (((AVD02Projects.OrderNumber) Between [Forms]![rptAVD02PrincipalCommission]![ONrFrom] And [Forms]![rptAVD02PrincipalCommission]![ONrTo]) AND ((AVD02Projects.OrderDate) Between [Forms]![rptAVD02PrincipalCommission]![PeriodFrom] And [Forms]![rptAVD02PrincipalCommission]![PeriodTo]) AND ((Principals.PrincipalID)=[Forms]![rptAVD02PrincipalCommission]![PrincipalID])) OR ((([Forms]![rptAVD02PrincipalCommission]![PrincipalID])='*'));
You help...
I have a Form that produces a report. The first control is a combobox vith a list of names. I have also made it possible to choose "all" in the list.
The second control is for getting orders with date "from and "To".
The third is complicating things for me.
I would like a similar "From" - "To" fields as the date only with oredernumber instead, but I cant get it to work.
If I choose one name from the list it works, but if I choose not to enter ordernumber from/to I get nothing. I need help with the code that will return results even if the ordernumber-fields are left blank.
The second problem is that if I choose "All" and enter date and ordernumber it returns all ordernumbers, and not just those within the range that I entered..
The code that i use is:
WHERE (((AVD02Projects.OrderNumber) Between [Forms]![rptAVD02PrincipalCommission]![ONrFrom] And [Forms]![rptAVD02PrincipalCommission]![ONrTo]) AND ((AVD02Projects.OrderDate) Between [Forms]![rptAVD02PrincipalCommission]![PeriodFrom] And [Forms]![rptAVD02PrincipalCommission]![PeriodTo]) AND ((Principals.PrincipalID)=[Forms]![rptAVD02PrincipalCommission]![PrincipalID])) OR ((([Forms]![rptAVD02PrincipalCommission]![PrincipalID])='*'));
You help...