run time error 424 object required

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lapchien

    run time error 424 object required

    Debug stops at the 3rd line of this code (Set rs =
    db.openrecordse t("IMPORT") why?


    Private Sub Command118_Clic k()
    Dim rs As DAO.Recordset
    Set rs = db.openrecordse t("IMPORT")
    With rs
    .MoveFirst
    prev = !NOM_ACCOUNT
    .MoveNext
    Do
    Select Case prev
    Case "1700"
    If !NOM_ACCOUNT <> "2300" Then
    MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
    "Validation failed", , "Error"
    Exit Sub 'or Exit Function
    End If
    Case "2300"
    If !NOM_ACCOUNT <> "3200" Then
    MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
    "Validation failed", , "Error"
    Exit Sub 'or Exit Function
    End If
    Case "3200"
    If !NOM_ACCOUNT <> "1700" Then
    MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
    "Validation failed", , "Error"
    Exit Sub 'or Exit Function
    End If
    End Select
    prev = !NOM_ACCOUNT
    .MoveNext
    Loop Until .EOF
    .Close
    End With
    Set rs = Nothing
    Set db = Nothing
    End Sub



    --
    Thanks,
    Chris
    cc8345@NOSPAMec lipse.co.uk


  • HJ

    #2
    Re: run time error 424 object required

    You should declare db as well.

    Private Sub Command118_Clic k()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set rs = db.openrecordse t("IMPORT")
    ....

    HJ


    "Lapchien" <cc8345@NOSPAMe clipse.co.uk> wrote in message
    news:1062231335 .595338@ananke. eclipse.net.uk. ..[color=blue]
    > Debug stops at the 3rd line of this code (Set rs =
    > db.openrecordse t("IMPORT") why?
    >
    >
    > Private Sub Command118_Clic k()
    > Dim rs As DAO.Recordset
    > Set rs = db.openrecordse t("IMPORT")
    > With rs
    > .MoveFirst
    > prev = !NOM_ACCOUNT
    > .MoveNext
    > Do
    > Select Case prev
    > Case "1700"
    > If !NOM_ACCOUNT <> "2300" Then
    > MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
    > "Validation failed", , "Error"
    > Exit Sub 'or Exit Function
    > End If
    > Case "2300"
    > If !NOM_ACCOUNT <> "3200" Then
    > MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
    > "Validation failed", , "Error"
    > Exit Sub 'or Exit Function
    > End If
    > Case "3200"
    > If !NOM_ACCOUNT <> "1700" Then
    > MsgBox "There has been an error in row # " & !NOM_ID & vbCrLf &
    > "Validation failed", , "Error"
    > Exit Sub 'or Exit Function
    > End If
    > End Select
    > prev = !NOM_ACCOUNT
    > .MoveNext
    > Loop Until .EOF
    > .Close
    > End With
    > Set rs = Nothing
    > Set db = Nothing
    > End Sub
    >
    >
    >
    > --
    > Thanks,
    > Chris
    > cc8345@NOSPAMec lipse.co.uk
    >
    >[/color]


    Comment

    • Deano

      #3
      Re: run time error 424 object required

      HJ wrote:[color=blue]
      > You should declare db as well.
      >
      > Private Sub Command118_Clic k()
      >
      > Dim db As DAO.Database
      > Dim rs As DAO.Recordset
      > Set rs = db.openrecordse t("IMPORT")[/color]

      I think you should set it as well;

      Set db = Currentdb()

      [color=blue]
      >
      > HJ
      >
      >
      > "Lapchien" <cc8345@NOSPAMe clipse.co.uk> wrote in message
      > news:1062231335 .595338@ananke. eclipse.net.uk. ..[color=green]
      >> Debug stops at the 3rd line of this code (Set rs =
      >> db.openrecordse t("IMPORT") why?
      >>
      >>
      >> Private Sub Command118_Clic k()
      >> Dim rs As DAO.Recordset
      >> Set rs = db.openrecordse t("IMPORT")
      >> With rs
      >> .MoveFirst
      >> prev = !NOM_ACCOUNT
      >> .MoveNext
      >> Do
      >> Select Case prev
      >> Case "1700"
      >> If !NOM_ACCOUNT <> "2300" Then
      >> MsgBox "There has been an error in row # " & !NOM_ID &
      >> vbCrLf & "Validation failed", , "Error"
      >> Exit Sub 'or Exit Function
      >> End If
      >> Case "2300"
      >> If !NOM_ACCOUNT <> "3200" Then
      >> MsgBox "There has been an error in row # " & !NOM_ID &
      >> vbCrLf & "Validation failed", , "Error"
      >> Exit Sub 'or Exit Function
      >> End If
      >> Case "3200"
      >> If !NOM_ACCOUNT <> "1700" Then
      >> MsgBox "There has been an error in row # " & !NOM_ID &
      >> vbCrLf & "Validation failed", , "Error"
      >> Exit Sub 'or Exit Function
      >> End If
      >> End Select
      >> prev = !NOM_ACCOUNT
      >> .MoveNext
      >> Loop Until .EOF
      >> .Close
      >> End With
      >> Set rs = Nothing
      >> Set db = Nothing
      >> End Sub
      >>
      >>
      >>
      >> --
      >> Thanks,
      >> Chris
      >> cc8345@NOSPAMec lipse.co.uk[/color][/color]



      Comment

      • HJ

        #4
        Re: run time error 424 object required

        Yes, you are right. Forgot to mention that.

        HJ

        "Deano" <martinday66999 @hotmail.com> wrote in message
        news:Dz04b.1978 $4L1.397513@war ds.force9.net.. .[color=blue]
        > HJ wrote:[color=green]
        > > You should declare db as well.
        > >
        > > Private Sub Command118_Clic k()
        > >
        > > Dim db As DAO.Database
        > > Dim rs As DAO.Recordset
        > > Set rs = db.openrecordse t("IMPORT")[/color]
        >
        > I think you should set it as well;
        >
        > Set db = Currentdb()
        >
        >[color=green]
        > >
        > > HJ
        > >
        > >
        > > "Lapchien" <cc8345@NOSPAMe clipse.co.uk> wrote in message
        > > news:1062231335 .595338@ananke. eclipse.net.uk. ..[color=darkred]
        > >> Debug stops at the 3rd line of this code (Set rs =
        > >> db.openrecordse t("IMPORT") why?
        > >>
        > >>
        > >> Private Sub Command118_Clic k()
        > >> Dim rs As DAO.Recordset
        > >> Set rs = db.openrecordse t("IMPORT")
        > >> With rs
        > >> .MoveFirst
        > >> prev = !NOM_ACCOUNT
        > >> .MoveNext
        > >> Do
        > >> Select Case prev
        > >> Case "1700"
        > >> If !NOM_ACCOUNT <> "2300" Then
        > >> MsgBox "There has been an error in row # " & !NOM_ID &
        > >> vbCrLf & "Validation failed", , "Error"
        > >> Exit Sub 'or Exit Function
        > >> End If
        > >> Case "2300"
        > >> If !NOM_ACCOUNT <> "3200" Then
        > >> MsgBox "There has been an error in row # " & !NOM_ID &
        > >> vbCrLf & "Validation failed", , "Error"
        > >> Exit Sub 'or Exit Function
        > >> End If
        > >> Case "3200"
        > >> If !NOM_ACCOUNT <> "1700" Then
        > >> MsgBox "There has been an error in row # " & !NOM_ID &
        > >> vbCrLf & "Validation failed", , "Error"
        > >> Exit Sub 'or Exit Function
        > >> End If
        > >> End Select
        > >> prev = !NOM_ACCOUNT
        > >> .MoveNext
        > >> Loop Until .EOF
        > >> .Close
        > >> End With
        > >> Set rs = Nothing
        > >> Set db = Nothing
        > >> End Sub
        > >>
        > >>
        > >>
        > >> --
        > >> Thanks,
        > >> Chris
        > >> cc8345@NOSPAMec lipse.co.uk[/color][/color]
        >
        >
        >[/color]


        Comment

        Working...