Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2008
    Posts
    7

    Red face Unanswered: 424 Object Required Error

    Hi,

    I have below code on Form_Load() , I get one time error when I open this form.

    424 Object required, please help ASAP.


    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

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Comment out the "On Error" bit and tell us which line is causing the error please.
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2008
    Posts
    7

    Re:

    I removed all " On error part"

    and now it works fine.

    Thank you.

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Hahaha!!! That was unexpected

    Pro job George!
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Endless loop, anyone?

    You needed an Exit Sub in the exit handler.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •