Page 1 of 1

vbs type mismatch error in quotation breakout

PostPosted: Sun Apr 14, 2019 1:05 pm
by aegean66
Hi there,
Hoping someone can help with this vbs problem that has stumped me.
It is used in the Quotation section of JIWA 6.
Code is below and I get a type mismatch error.
Have tried quite a few things but oddly the exact same code in the sales order module works a treat?

'Read csv file and store values in variables

For i = 2 To osheet.usedrange.rows.count
vLineNumber = oSheet.Cells(i,1).Value
vFineLine = oSheet.Cells(i,4).Value
vQty = oSheet.Cells(i,5).Value
vPrice = oSheet.Cells(i,8).Value

'Call function to match value in spreadsheet to corresponding value in internal JIWA SQL database

If GetPartNo(SalesQuoteObject.Database, vFineLine, PartNo, lErrorModule, lErrorMessage) = False

Then
MsgBox lErrorModule & vbCrLf & lErrorMessage & "Line No "&(i-1)
Else

'Begin adding the items on spreadsheet to JIWA Quote
'Line below - in bold - (Line 75) produces error
'Type Mismatch: 'SalesQuoteObject.SalesQuoteLines.AddInventoryItem' at Line 75
'PartNo variable is definitely a string (they all contain text anyway)

ReturnCode = SalesQuoteObject.SalesQuoteLines.AddInventoryItem(PartNo, 1 , NewKey)
SalesQuoteObject.SalesQuoteLines(NewKey).QuantityOrdered = vQty
SalesQuoteObject.SalesQuoteLines(NewKey).SellPriceExGST = vPrice
SalesQuoteObject.SalesQuoteLines(NewKey).LineNumber = vLineNumber
End If

'Note I use EXACT same code in Sales order (except obviously replacing the SalesQuoteObject and SalesQuoteLines object)
'Calling same function. That works perfectly!

Next
Set oSheet = Nothing
oBook.Close
Set oBook = Nothing
oXL.Quit
Set oXL = Nothing

End Sub

Re: vbs type mismatch error in quotation breakout

PostPosted: Mon Apr 15, 2019 10:21 am
by aegean66
Further to this:

THIS WORKS PEREFECTLY

ReturnCode = SalesOrderObject.SalesOrderLines.AddInventoryItem("CHEMBRU006", 1, NewKey)
SalesOrderObject.SalesOrderLines(NewKey).QuantityOrdered = 12


THIS DOESN'T WORK ( It produces error 'Type Mismatch: 'SalesQuoteObject.SalesQuoteLines.AddInventoryItem' at Line 75)

ReturnCode = SalesQuoteObject.SalesQuoteLines.AddInventoryItem("CHEMBRU006", 1, NewKey)
SalesQuoteObject.SalesQuoteLines(NewKey).QuantityOrdered = 12

Re: vbs type mismatch error in quotation breakout

PostPosted: Tue Apr 16, 2019 11:16 am
by Mike.Sheen
All I can tell you is the the signature for the SalesOrderLines AddInventoryItem is identical to that of the QuoteLines AddInventoryItem in 06.05.13

So, there should be no difference in behaviour.

Re: vbs type mismatch error in quotation breakout

PostPosted: Wed Apr 17, 2019 10:03 am
by aegean66
Thanks for responding Mike

I have literally used only these two lines of code - Sales Order works; Quotes don't.

Think I'll wait for an epiphany to strike before tackling again otherwise I'll end up in a dark corner sucking my thumb

Cheers,
Damon.

Re: vbs type mismatch error in quotation breakout

PostPosted: Wed Apr 17, 2019 10:14 am
by Mike.Sheen
The version of Jiwa may be relevant - are you using 06.05.13?

Re: vbs type mismatch error in quotation breakout

PostPosted: Thu Apr 18, 2019 1:28 pm
by aegean66
Definitely 6.5.13.

Screenshot with code and error below.

https://www.dropbox.com/s/0ha6kwsq8ocvg2m/ScreenShot.gif?dl=0

Re: vbs type mismatch error in quotation breakout

PostPosted: Tue Apr 30, 2019 4:25 pm
by aegean66
Believe it or not !!!

I used the two lines below and got a "type mismatch" error (as previously reported)

ReturnCode = SalesQuoteObject.SalesQuoteLines.AddInventoryItem("CHEMBRU066", 1, NewKey)
SalesQuoteObject.SalesQuoteLines(NewKey).QuantityOrdered = 12

After playing around for a while I decided to use the following code (Note the use of Cstr)

ReturnCode = SalesQuoteObject.SalesQuoteLines.AddInventoryItem("CHEMBRU066", 1, CStr(NewKey))
SalesQuoteObject.SalesQuoteLines(NewKey).QuantityOrdered = 12

It WORKED (populated the quote) but failed on the second line ("object required")

Here is the kicker though; I go back to the original code and it also worked for the first line, but again got an "object required" error for the second line (Why?).

I will solve this! it's in my DNA dammit.