-
April 7th, 2014, 09:29 AM
#1
Data Type Mismatch in criteria expression
when i save a record to access through error
Run time error - Data Type Mismatch in criteria expression
and when i go to debug...it directs to ".Open sSQL, sConnection, adOpenKeyset, adLockOptimistic" to this.
Please sugesst
-
April 7th, 2014, 10:32 AM
#2
Re: Data Type Mismatch in criteria expression
There is a lot of discussions about this error message:
https://www.google.com/search?source...sion&gs_htsa=1
Did you look at at least some of them?
Victor Nijegorodov
-
April 8th, 2014, 12:59 AM
#3
Re: Data Type Mismatch in criteria expression
Data Type mismatch means that one or more of your data types in the query does not match what is in the database. This happens when you try to apply a numeric value to a text field or a text value to a numeric field or non date value to a date field.
Simple problem that you should be able to resolve but if you can't then the first step is to show us the query and would also help to know what types of fields are in the db in question
Always use [code][/code] tags when posting code.
-
April 8th, 2014, 09:51 AM
#4
Re: Data Type Mismatch in criteria expression
Show your query and table structure, as DM said
-
April 9th, 2014, 10:18 AM
#5
Re: Data Type Mismatch in criteria expression
Code:
Private Sub cmdSave_Click()
Dim cnuser As New ADODB.connection
Dim rsuser As New ADODB.Recordset
If sempty(txtFulNa.Text) = True Then Exit Sub
If sempty(txtFan.Text) = True Then Exit Sub
If sempty(txtEdate.Text) = True Then Exit Sub
If sempty(txtShaha.Text) = True Then Exit Sub
If sempty(txtSeno.Text) = True Then Exit Sub
If sempty(txtFisNa.Text) = True Then Exit Sub
If sempty(txtSecNa.Text) = True Then Exit Sub
'If sempty(txtLasNa.Text) = True Then Exit Sub
If sempty(txt1stID.Text) = True Then Exit Sub
If sempty(txtExpDate.Text) = True Then Exit Sub
If sempty(txtMob.Text) = True Then Exit Sub
If sempty(txtChq.Text) = True Then Exit Sub
If sempty(Combo1.Text) = True Then Exit Sub
If sempty(Combo3.Text) = True Then Exit Sub
If sempty(txtPrn.Text) = True Then Exit Sub
Call connection(cnuser, App.Path & "\Commissions.mdb", "endromida")
'Call connection(cnuser, "\\mika\medrar\Commissions.mdb", "endromida")
Call Recordset(rsuser, cnuser, "SELECT * FROM commi_cus")
With rsuser
.AddNew
Call shasta
.Fields!funa = txtFulNa.Text
.Fields!Sha_no = txtShaha.Text
.Fields!Edate = txtEdate.Text
.Fields!tr_no = txtSeno.Text
.Fields!fami_na = txtFan.Text
.Fields!first_na = txtFisNa.Text
.Fields!sec_na = txtSecNa.Text
If !last_na <> " " Then
.Fields!last_na = txtLasNa.Text
End If
.Fields!cus_id = txt1stID.Text
.Fields!cus_mo = txtMob.Text
.Fields!exp_date = txtExpDate.Text
.Fields!cus_mo = txtMob.Text
.Fields!ch_no = txtChq.Text
.Fields!ba = Combo1
.Fields!tran_co = Combo3
.Fields!pro_na = txtPrn.Text
.Fields!sta = txtstat.Text
.Update
End With
MsgBox "Successfully Saved.", vbInformation
Call cmdRePrint_Click
Call clear
Set cnuser = Nothing
Set rsuser = Nothing
End Sub
When i use Save...
it will debug to
Code:
Public Sub Recordset(ByRef sRecordset As ADODB.Recordset, ByRef sConnection As ADODB.connection, ByVal sSQL As String)
With sRecordset
.CursorLocation = adUseClient
.Open sSQL, sConnection, adOpenKeyset, adLockOptimistic
End With
End Sub
-
April 9th, 2014, 12:03 PM
#6
Re: Data Type Mismatch in criteria expression
Are you sure that is where the error is? The message indicates a where clause but none exists in the code you have shown
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|