Good day all,
I have been trying to resolve those 2 problems, but so far unsuccessful, probably didn't asked the right question. Would appreciate your kind help.
Problem 1.
The following code was showing #num! if [cboDeptStats] was left blank, after I added the iff(Nz.. function to what I used to had, it works ok, but still shows #num! if there isn't any records for specific month in the query. Can you please advice, how to edit this line.
Problem 2.
I have a form with a print button, What I want it to do, is run the query and check if there is any matching records, if so, print the report, if there isn't any, show a message box.
Field name in current form: qaQAPK
matching field in the query: tQAFK
query name: Q_printTask
I have been trying to resolve those 2 problems, but so far unsuccessful, probably didn't asked the right question. Would appreciate your kind help.
Problem 1.
The following code was showing #num! if [cboDeptStats] was left blank, after I added the iff(Nz.. function to what I used to had, it works ok, but still shows #num! if there isn't any records for specific month in the query. Can you please advice, how to edit this line.
Code:
=IIf(Nz([cboDeptStats],0)=0,0,DCount("tTaskPK","Q_task_CompStats","tTaskDueDate>=tTaskComplDate AND Month([tTaskDueDate]) = 7 AND qaDeptFK=[Forms]![F_CompLvl]![cboDeptStats]")/DCount("tTaskPK","Q_task_CompStats","Month([tTaskDueDate]) = 7 AND qaDeptFK=[Forms]![F_CompLvl]![cboDeptStats]"))
Problem 2.
I have a form with a print button, What I want it to do, is run the query and check if there is any matching records, if so, print the report, if there isn't any, show a message box.
Field name in current form: qaQAPK
matching field in the query: tQAFK
query name: Q_printTask
Code:
Private Sub cmdPrintActions_Click()
'Print Actions for current record
'using R_printQA.
If IsNull([tQAFK,Q_printTask]) Then
MsgBox "No Records available for print", _
vbOKOnly, "Error"
Exit Sub
End If
DoCmd.OpenReport "R_printTask", acPreview, , _
"tQAFK = " & Me!qaQAPK
End Sub