Quantcast
Channel: Tech Support Guy
Viewing all articles
Browse latest Browse all 38405

Help needed

$
0
0
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


Viewing all articles
Browse latest Browse all 38405

Trending Articles