hi? im trying to add an item with no expiry date but it keeps on having an error “Data type mismatch in criteria expression.”
datafield of txtExpiry.text is Date/time in database
heres my sample of code:
Function SaveRecord()
If txtCategory.Text <> “” And txtStock.Text <> “” And txtIname.Text <> “” And txtQuant.Text <> “” And txtSupplier.Text <> “” Then
If AEswitch = “a” Then
populate(da, dset, “Select * from tblItems where Category=’” & txtCategory.Text & “’ and Stock_No=’” & txtStock.Text & “’ and Item_Name=’” & txtIname.Text & “’ and Description=’” & txtDesc.Text & “’ and Measurement=’” & txtMeas.Text & “’”, “tblItems”)
If totRec = 0 Then
‘If txtExpiry.Text <> “” Then
komPak(kom, "insert into tblItems(Category,Stock_No,Item_Name,Description,Measurement,Quantity,Expiry_Date,Remarks,Supplier_Name) values (’" & txtCategory.Text & “’,’” & txtStock.Text & “’,’” & txtIname.Text & “’,’” & txtDesc.Text & “’,’” & txtMeas.Text & “’,val(’” & txtQuant.Text & “’),cdate(’” & txtExpiry.Text & “’),’” & txtRemarks.Text & “’, '” & txtSupplier.Text & “’)”)
‘Else
’ komPak(kom, "insert into tblItems(Category,Stock_No,Item_Name,Description,Measurement,Quantity,Expiry_Date,Remarks,Supplier_Name) values (’" & txtCategory.Text & “’,’” & txtStock.Text & “’,’” & txtIname.Text & “’,’” & txtDesc.Text & “’,’” & txtMeas.Text & “’,’” & txtQuant.Text & “’,’#00/00/000’,’” & txtRemarks.Text & “’, '” & txtSupplier.Text & “’)”)
'End If
Me.Close()
Else
M(“Item already Exist”)
End If
Else
'for update
If txtCategory.Text <> "" And txtStock.Text <> "" And txtIname.Text <> "" And txtQuant.Text <> "" And txtSupplier.Text <> "" Then
' populate(da, dset, "Select * from tblItems where Category='" & txtCategory.Text & "' and Item_Name='" & txtIname.Text & "' and Description='" & txtDesc.Text & "' and Measurement='" & txtMeas.Text & "'", "tblItems")
' If totRec = 0 Then
komPak(kom, "update tblItems set Category='" & txtCategory.Text & "',Stock_No='" & txtStock.Text & "',Item_Name='" & txtIname.Text & "',Description='" & txtDesc.Text & "',Measurement='" & txtMeas.Text & "',Quantity='" & txtQuant.Text & "',Expiry_Date='" & txtExpiry.Text & "',Remarks='" & txtRemarks.Text & "', Supplier_Name='" & txtSupplier.Text & "' where ItemID=val('" & frmItems.txtED.Text & "')")
M("Item Details Updated")
Me.Close()
'Else
' M("Item already Exist")
'End If
End If
End If
Else
M("Empty not allowed")
End If
Return True
End Function