Solved Syntax Error? (1 Viewer)

asteropi

Member
Local time
Today, 13:39
Joined
Jun 2, 2024
Messages
90
I seem to be blind but I can't find the error here.
All it tells me is "Expected: =" but I don't think I'm missing one. Can you please tell me where I'm wrong?

Code:
IIF("Paid"=False,docmd.OpenReport(QuotationR),IIF("Paid"=True & "AND CustomerType=" & "Χονδρικής", docmd.OpenReport(OrderInvoiceR),docmd.OpenReport(ReceiptR)))
 
You can't use a VBA command within the IIf() expression like that.

Also, the result of your IIf() function must be assigned to something. Here you probable just want a standard If ... End If expression

eg:
Code:
IF "Paid" = False Then     ' If "Paid" is a control or field then remove the double quotes
  DoCmd.OpenReport "QuotationR"
ElseIf "Paid" = True & CustomerType = "Χονδρικής" Then    ' Ditto re. "Paid"
  DoCmd.OpenReport "OrderInvoiceR"
Else
  DoCmd.OpenReport "ReceiptR"
End If

Where are you trying to use this expression?
 
for a print invoice button. I wrote it in the vba
 
Be careful because, as it's written (with the double quotes around "Paid"), then you will never open report QuotationR.
 
(We crossed posts) (y)
scratch that only half solved.

It accepts the first If but then skips the 2nd and jumps straight to the ReceiprR report.
This is how it is now

Code:
If Paid = False Then
  DoCmd.OpenReport "QuotationR", acViewReport
ElseIf Paid = True & CustomerType = "Χονδρικής" Then
  DoCmd.OpenReport "OrderInvoiceR", acViewReport
Else
  DoCmd.OpenReport "ReceiptR", acViewReport
End If
 

Users who are viewing this thread

Back
Top Bottom