I'm trying to connect SQL Server to Access. I have the connection function in a module. I call this function in another module.
Here is the code in my module:
'Variabel voor SQL Server Connectie
Public SQLConnectie As ADODB.Connection
'Connecten met SQL Server
Public Function DBConn() As ADODB.Connection
If Not (SQLConnectie Is Nothing) Then
Set SQLConnectie = New ADODB.Connection
With SQLConnectie
.CommandTimeout = 15
.Mode = adModeReadWrite
.ConnectionString = "Provider=SQLNCLI11;Server=dafehvmvdsql3;Database=PROVOMotorenfabriek;Integrated Security=SSPI; Persist Security Info=False"
.Open
End With
End If
Set DBConn = SQLConnectie
Set SQLConnectie = Nothing
End Function
And below the code in the module which executes the stored procedure in SQL Server:
Call DBConn.Execute("EXEC spStoringToevoegen " & productielijnMW & ", " & Forms(Formnaam)!cbLijngedeelte & ".............etc
I get the error: Object variable or With block variable not set. Every answer I find says I need to put set in front of some variables but I can't find which one this should be.
Thanks in advance,