Hi,
I have below code on Form_Load() , I get one time error when I open this form.
424 Object required, please help ASAP.
I have below code on Form_Load() , I get one time error when I open this form.
424 Object required, please help ASAP.
Code:
Option Compare Database
Private Sub Form_Load()
On Error GoTo ThisFormError
Dim cnt As ADODB.Connection
Dim rst1 As ADODB.Recordset
Dim stDB As String
Dim stSQL1 As String
Dim stConn As String
'Instantiate the ADO-objects.
Set cnt = New ADODB.Connection
Set rst1 = New ADODB.Recordset
'Path to the database.
stDB = "\\server23\abc\db.mdb"
'Create the connectionstring.
stConn = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & stDB & ";Persist Security Info=False"
cnt.Open (stConn)
stSQL1 = "SELECT DISTINCT [table 1].[CH#] FROM [table1];"
rst1.Open stSQL1, cnt, adOpenForwardOnly, adLockReadOnly, adCmdText
rst1.MoveFirst
With Me.Cmb_StoreNo
Cmb_StoreNo.AddItem ("All ")
Do While Not rst1.EOF
Cmb_StoreNo.AddItem rst1![CH#]
rst1.MoveNext
Loop
End With
ThisFormErrorExit:
On Error Resume Next
rst.Close
Set rst = Nothing
cnt.Close
Set cnt = Nothing
ThisFormError:
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical, "Error!"
Resume ThisFormErrorExit
End Sub
Comment