Hi All
I'm fairly new to VBA, so please be gentle.
I keep getting the error, 'Run time error 91: Object Variable not set' etc. with the following code.
Can anyone help?
Thanks in advance
Code ---
Sub Button1_Click()
'
'
Dim cmd As ADODB.Command
Set cnn = New ADODB.Connection
Set cmd = New ADODB.Command
Dim rs As ADODB.Recordset
Dim DSht As Worksheet
Dim sql As String
cnn.Open ("~~~")
UserForm1.Show
sql = "~~~~"
cnn.Execute (sql)
DSht.Range("A8").CopyFromRecordset rs
cnn.Close
End Sub
I'm fairly new to VBA, so please be gentle.
I keep getting the error, 'Run time error 91: Object Variable not set' etc. with the following code.
Can anyone help?
Thanks in advance
Code ---
Sub Button1_Click()
'
'
Dim cmd As ADODB.Command
Set cnn = New ADODB.Connection
Set cmd = New ADODB.Command
Dim rs As ADODB.Recordset
Dim DSht As Worksheet
Dim sql As String
cnn.Open ("~~~")
UserForm1.Show
sql = "~~~~"
cnn.Execute (sql)
DSht.Range("A8").CopyFromRecordset rs
cnn.Close
End Sub