Hi
I have to output records on a report based on user inputs.
I have written the code below that populates a table and then creates a query. I was hoping then to base a report on the query created and run it within the same sub, but I get an error 'expression is too complex...'
ViRi
I have to output records on a report based on user inputs.
I have written the code below that populates a table and then creates a query. I was hoping then to base a report on the query created and run it within the same sub, but I get an error 'expression is too complex...'
Code:
Private Sub Command23_Click()
On Error GoTo Err_Command23_Click
Dim db As DAO.Database
Dim rsLookUpClient As DAO.QueryDef
Dim strSQL As String
Dim Client As String
Dim DateStart As Date
Dim DateEnd As Date
Dim stDocNameDel As String
Dim stDocNameCr As String
Dim stDocNameInv As String
Set db = CurrentDb
stDocNameDel = "qryDel"
stDocNameCr = "qryCrdS"
stDocNameInv = "qryInvS"
DoCmd.OpenQuery stDocNameDel, acNormal, acEdit
DoCmd.OpenQuery stDocNameCr, acNormal, acEdit
DoCmd.OpenQuery stDocNameInv, acNormal, acEdit
Client = InputBox("Enter a Client")
DateStart = InputBox("Enter Statement Start Date")
DateEnd = InputBox("Enter Statement End Date")
strSQL = "SELECT tblStatement.DateI, tblStatement.InvoiceNo, tblStatement.SumOfTo, tblStatement.DateC, tblStatement.CreditNo, tblStatement.SumOfT, tblStatement.ClientName FROM tblStatement WHERE tblStatement.DateI = DateStart OR tblStatement.DateI = DateEnd & tblStatement.DateC = DateStart OR tblStatement.DateC = DateEnd & tblStatement.ClientName = Client;"
Set rsLookUpClient = db.CreateQueryDef("qyStatement", strSQL)
Exit_Command23_Click:
Exit Sub
Err_Command23_Click:
MsgBox Err.Description
Resume Exit_Command23_Click
End Sub
ViRi