howling_muffin
New member
- Local time
- Today, 07:04
- Joined
- Jul 29, 2020
- Messages
- 11
I'm trying to use a generic function to execute sql queries in my Access database, but I'm really stuck on the overflow error that keeps coming up.
Here's where I call it:
Each time I run this, I get an overflow error on the line Set ExecuteParameters = cmd.Execute(). For the past three days I've tried everything I can think of with no success. Does anyone have any idea why this error has decided to take up residence on this line? Much appreciation for anyone who can point me in the right direction.
Code:
Public Function ExecuteParameters(sql As String, ParamArray Params() As Variant) As ADODB.Recordset
Dim cmd As New ADODB.Command
Dim inputParam As Variant
cmd.ActiveConnection = Procs.getConn
cmd.CommandText = sql
For Each inputParam In Params
Set inputParam = cmd.CreateParameter(, GetParameterType(inputParam), 1, Len(Nz(inputParam)), inputParam)
cmd.Parameters.Append inputParam
Next inputParam
cmd.CommandType = adCmdText
Set ExecuteParameters = cmd.Execute()
Set cmd = Nothing
End Function
Here's where I call it:
Code:
ExecuteParameters("SELECT * FROM ? WHERE ? = ?", "Students", "StudentID", 32)
Each time I run this, I get an overflow error on the line Set ExecuteParameters = cmd.Execute(). For the past three days I've tried everything I can think of with no success. Does anyone have any idea why this error has decided to take up residence on this line? Much appreciation for anyone who can point me in the right direction.