monoDeveloper
Programmer
- Apr 16, 2013
- 16
Hi everybody
I write this script to insert then check insertion done or not
But I get error message " "Data type mismatch in criteria Expression" on line [highlight #FCE94F]Set rs = db.OpenRecordset (strSQL)
[/highlight]
When I try to run the select statement as you will see in coming code:
Private Sub cmd_Create_Request_Click()
'Run Insert new suppy_request query
DoCmd.RunSQL (" INSERT INTO SupplyRequest( supplierID, supp_Req_Date, Creator_U_ID) " & _
" Values ( " & _
"[Forms]![frm_Add_Supply_Request]![cboSupplier], " & _
"[Forms]![frm_Add_Supply_Request]![txtDate], " & _
"[Forms]![frm_Add_Supply_Request]![txtEmpNumber] )")
'================
'Run SQL statement to confirm Insertion process done
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim intResult As Integer
'Open a snapshot-type Recordset based on an SQL statement
inResult = txtRequestNumber
strSQL = (" SELECT supp_Req_SN FROM SupplyRequest WHERE( supp_Req_SN = '" & inResult & "')")
Set db = CurrentDb
Set rs = db.OpenRecordset (strSQL)
intResultConfirm = rs.RecordCount
rs.Close
Set rs = Nothing
Set db = Nothing
If (inResultConfirm > 0) Then
MsgBox "Insertion Process done... Record # " + intResultConfirm
inResult = DMax("supp_Req_SN", "SupplyRequest") + 1
Me.txtRequestNumber = inResult
Else
MsgBox "Data process failed", vbInformation
End If
End Sub
----
Can anybody find the incorrect point & tell me how to correct it.
Will be waiting
I write this script to insert then check insertion done or not
But I get error message " "Data type mismatch in criteria Expression" on line [highlight #FCE94F]Set rs = db.OpenRecordset (strSQL)
[/highlight]
When I try to run the select statement as you will see in coming code:
Private Sub cmd_Create_Request_Click()
'Run Insert new suppy_request query
DoCmd.RunSQL (" INSERT INTO SupplyRequest( supplierID, supp_Req_Date, Creator_U_ID) " & _
" Values ( " & _
"[Forms]![frm_Add_Supply_Request]![cboSupplier], " & _
"[Forms]![frm_Add_Supply_Request]![txtDate], " & _
"[Forms]![frm_Add_Supply_Request]![txtEmpNumber] )")
'================
'Run SQL statement to confirm Insertion process done
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim intResult As Integer
'Open a snapshot-type Recordset based on an SQL statement
inResult = txtRequestNumber
strSQL = (" SELECT supp_Req_SN FROM SupplyRequest WHERE( supp_Req_SN = '" & inResult & "')")
Set db = CurrentDb
Set rs = db.OpenRecordset (strSQL)
intResultConfirm = rs.RecordCount
rs.Close
Set rs = Nothing
Set db = Nothing
If (inResultConfirm > 0) Then
MsgBox "Insertion Process done... Record # " + intResultConfirm
inResult = DMax("supp_Req_SN", "SupplyRequest") + 1
Me.txtRequestNumber = inResult
Else
MsgBox "Data process failed", vbInformation
End If
End Sub
----
Can anybody find the incorrect point & tell me how to correct it.
Will be waiting