Type Mismatch error SQL query

mchong71

New Member
Joined
Oct 28, 2010
Messages
8
So I'm trying to copy databases over to another in order to revamp them. I'm having trouble with two different databases. Both are used to pull data from an existing table and the information is used to pull other data. You should note that the same code is used in the original database and is very much functional, it is only when I copy it over do I get this problem.

Here is the code from the first database:

This line "Set prm = dbs.QueryDefs("Qry - Inventory Balance").Parameters("prtNum")" finds a part number and updates the quantity of the parts available in a form, but instead gives me a type mismatch error

Private Sub getQtyAvailable()
'the following DAO code is necessary and should not be removed. If an upgrade takes place,
'it will not interfere and should still work... as long as the Microsoft DAO reference library 3.6 is linked.
Dim dbs As Database, rst As Recordset, prm As Parameter
Set dbs = CurrentDb
Set prm = dbs.QueryDefs("Qry - Inventory Balance").Parameters("prtNum")
On Error GoTo Error_NotInList
prm.Value = Part_Number.Value
Set rst = dbs.QueryDefs("Qry - Inventory Balance").OpenRecordset(dbOpenDynaset)
Text125.Value = rst.Fields(0)
Exit_Command296_Click:
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
Set prm = Nothing
Exit Sub
Err_Command296_Click:
Resume Exit_Command296_Click
Error_NotInList:
Text125.Value = 0

rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
Set prm = Nothing
End Sub


Here is the code of the second database:

Pretty self explanatory....used in adding a user to the database, set rs=db.OpenRecordset(sql) yield the error.


sql = "SELECT username FROM Tbl_Login WHERE username = '" & Text3.Value & "'"
Set rs = db.OpenRecordset(sql)
If rs.EOF Then
If Option35.Value = -1 Then
MsgBox "Please note that Admin accounts cannot be deleted from the database for security reasons."
End If
Response = MsgBox("Are you sure you want to add this user to the database?", vbYesNo)
If Response = vbYes Then
sql = "INSERT INTO Tbl_Login (Username, Password, Email, Privileges) VALUES ('" & Text3.Value & "' , '" _
& Text31.Value & "' , '" & Text33.Value & "' , '" & privileges & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL sql
DoCmd.SetWarnings True
MsgBox "User " & Text3.Value & " added to database"
Call Option20_Click


ANY IDEAS WOULD BE GREATLY APPRECIATED!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top