Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro Syntax Error on Browse 1

Status
Not open for further replies.

vbdbcoder

Programmer
Nov 23, 2006
247
US
I am working on a VBA macro to import to AP invoices. The environment is version 6.0A.

The code breaks on the .Browse line, only when the invoice number has space, e.g. strInvoiceNumber = "2345 Summer Break". The session error returned is "- Criteria error. Syntax error. Invalid boolean."
But Accpac invoice number field allows space when enter manually. Is there a fix?

'-------- validate document number, type and vendor
strDocType = Trim(.Fields("Type"))
strInvoiceNumber = Trim(.Fields("InvoiceNumber")) '& "AAA"
vAPIBH.Init
vAPIBH.Browse "IDVEND=" & Chr(32) & strVendorID & Chr(32) & " AND IDINVC=" & Chr(32) & strInvoiceNumber & Chr(32) & " AND TEXTTRX =" & strDocType, True
If vAPIBH.Fetch = True Then
Print #1, "Data Error (Routine: ComanyInvoices): Company: " & strCompanyDesc & " Vendor ID: " & strVendorID & " Document Number: " & strInvoiceNumber & " Type: " & strDocType & " already exist."
intErrorValidate = intErrorValidate + 1
intErrorCount = intErrorCount + 1
End If

Thanks
 
vAPIBH.Browse "IDVEND=""" & strVendorID & """ AND IDINVC= """ & strInvoiceNumber & """ AND TEXTTRX = " & strDocType, True
 
If that doesn't work then make sure that your strInvoiceNumber variable value isn't longer than the maximum document width.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top