Type Mismatch (1 Viewer)

luzz

Registered User.
Local time
Today, 00:33
Joined
Aug 23, 2017
Messages
346
Hi all, I encounter this error "TYPE MISMATCH" when i click on my "save" button on my form.
Private Sub Write2DB(ByRef Arr As Variant)
'arr(0) PO#
'arr(1) GL#
'arr(2) Fabric Del Date
'arr(3) Fabrication
'arr(4) Fabric Width
'arr(5) Fabric Color
'arr(6) Net Weight
'arr(7) Gross Weight
'arr(8) Lbs

Lss = (CInt(Arr(7)) - CInt(Arr(6))) / CInt(Arr(6)) * 100 (Type mismatch on this line of code)
'Insert data to MaximMaintable by using SQL
CurrentDb.Execute _
"Insert into MaximMainTable (GLGPO,Mill,[Solid/Printing],Reference,FunctionalFinish,MRName,Buyer,MXDPO,GLA,StyleNo,FabricDelivery,GarmentDelDate,Country,Fabrication,AfterFabricWashWidth,Width,FinishedGoods,GSMPerSqYd,GSMAfterWash,Colour,GroundColour,ComboName,LabDipCode,SampleRequirement,GrossWeight,NettWeight,Lbs,Loss,Yds,Remarks,GarmentSketch,[GarmentSketch2],[GarmentSketch3],[GarmentSketch4],[GarmentSketch5],PrintedRemarks,FabricWeight,UnitPrice,Line,PPSample,POStatus,Amendment,SketchRemark1,SketchRemark2,SketchRemark3,SketchRemark4,SketchRemark5)" & _
"Values (" & Str(Arr(0)) & "','" & Me.cboMill & "','" _
& Me.cboSP & "','" & Me.cboReference & "','" _
& Me.cboFunctionalFinish & "','" & Me.txtMRName & "','" _
& Me.txtBuyer & "','" & Me.txtMXDPO & "','" _
& Str(Arr(1)) & "','" & Me.txtStyleNO & "','" _
& CDate(Arr(2)) & "','" & Me.txtGarmentDelDate & "','" _
& Me.txtCountry & "','" & Str(Arr(3)) & "','" _
& Me.txtFabricWashWidth & "','" & CLng(Arr(4)) & "','" _
& Me.txtFinishedGoods & "','" & Me.txtGSMsq & "','" _
& Me.txtGSMAfterWash & "','" & Str(Arr(5)) & "','" _
& Me.txtGroundColour & "','" & Me.txtComboName & "','" _
& Me.txtLabDipsCode & "','" & Me.txtBuyerRequirement & "','" _
& CLng(Arr(7)) & "','" & CLng(Arr(6)) & "','" & CLng(Arr(8)) _
& CLng(Lss) & "','" & Me.txtYds & "','" _
& Me.txtRemarks & "','" & Me.txtGarmentSketch & "','" _
& Me.txtGarmentSketch2 & "','" & Me.txtGarmentSketch3 & "','" _
& Me.txtGarmentSketch4 & "','" & Me.txtGarmentSketch5 & "','" _
& Me.txtPrintedRemarks & "','" & Me.txtFabricWeight & "','" _
& Me.txtUnitPrice & "','" & Me.txtLine & "','" & Me.txtPPSample & "','" _
& Me.txtPOStatus & "','" & Me.txtAmendment & "','" _
& Me.txtSketchRemark1 & "','" & Me.txtSketchRemark2 & "','" _
& Me.txtSketchRemark3 & "','" & Me.txtSketchRemark4 & "','" _
& Me.txtSketchRemark5 & "')"

'Click on save, all the fields in the textbox will be clear
cmdClear_Click
'Refresh data in list on form to show only data that are not save
Lst_PO.Requery
End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:33
Joined
Aug 30, 2003
Messages
36,127
The CInt() throw an error if tyhe value is Null. You can test for that first if it's possible.
 

luzz

Registered User.
Local time
Today, 00:33
Joined
Aug 23, 2017
Messages
346
The CInt() throw an error if tyhe value is Null. You can test for that first if it's possible.

I still encounter the same error even if the CInt() has value
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:33
Joined
Aug 30, 2003
Messages
36,127
Exactly what values do the array members contain when you get the error?
 

luzz

Registered User.
Local time
Today, 00:33
Joined
Aug 23, 2017
Messages
346
Exactly what values do the array members contain when you get the error?


Me.txtLoss = (CInt(Arr(7)) - CInt(Arr(6))) / CInt(Arr(6)) * 100

'me.txtlLoss contain 5

CInt(Arr(7)) contain "Gwe0

CInt(Arr(6))) contian "Net0"
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:33
Joined
Aug 30, 2003
Messages
36,127
How do you expect CInt() to turn "Net0" into an integer? It can't, thus the error.
 

Users who are viewing this thread

Top Bottom