I am quite new to VBA and SQL, and I am trying to populate a checkbox on a userform in Word's VBA with the column names of a SQL database. I have managed to verify the connection and list the elements in a table separately, now I just wanted to have them in the checkbox. The initializaiton has the following code:
Option Explicit
Dim rst As ADODB.Recordset
Dim conn As ADODB.Connection
Private Sub UserForm_Initialize()
Dim i As Integer
For i = 0 To rst.Fields.Count
Me.cboParameter.AddItem rst.Fields(i).Name
Next i
End Sub
When I try to run the private sub I get the run-time error 91 without any lines being highlighted. Any tips on what the problem might be?