Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2004
    Posts
    35

    Unanswered: Object required - recordsetclone

    I'd appreciate some help. What I'm doing is fairly simple and I have done this in the past but I keep getting error 424 Object required.

    I have form1 based on a table. A button links to a small form with 1 textbox (unbound) where the user types the text they want to search for. On Enter, they return to that record in form1. I have taken the code from another database where it works fine but in this one I get the error message.

    Here's my code:


    global declarations:
    Dim rst, rst2 As Recordset
    Dim db As Database
    Global whichForm As Form
    Global searchTxt, whichplName As String
    Global search as Integer

    form1 open:
    If IsLoaded(Me.Name) Then
    Set db = CurrentDb
    Set rst = whichForm.RecordsetClone
    ' debug.print rst.name at this point gives table name
    End If

    form1 close:
    If Not rst Is Nothing Then
    rst.Close
    Set rst = Nothing
    db.Close
    Set db = Nothing
    End If

    click button on form1:
    DoCmd.OpenForm "findPlacename", acNormal

    textbox on form2 after update:
    whichPlName = text1.text
    search = 1
    Forms(frm).SetFocus

    form1 activate:
    If search = 1 Then
    searchTxt = "Gaelic = '" & whichplName & "'"
    rst.FindFirst searchTxt ' error here
    If rst.NoMatch Then
    MsgBox ("Sorry, can't find that placename")
    Else
    Me.Bookmark = rst.Bookmark
    Me.[Placename].SetFocus
    End If
    search = 0
    DoCmd.Close acForm, "findPlacename"
    End If


    Public Function IsLoaded(ByVal form_name As String) As Boolean
    ' found this on this forum - thank you
    Dim frm As Form
    ' Return True if a form is loaded.

    IsLoaded = False
    For Each frm In Forms
    If frm.Name = form_name Then
    IsLoaded = True
    Set whichForm = Forms(frm.Name)
    Exit For
    End If
    Next frm
    End Function

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    One thing strikes me - when and where is whichForm instantiated? Also - do you know the offending line?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Ooops - spotted it

    Ok - do you know the offending line?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Ooops - found that too
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    What if you set your vars to public? Aren't they private at the mo....
    Code:
    Public rst, rst2 As Recordset
    Public db As Database
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Nov 2004
    Posts
    35

    Got it, thanks

    That was it, thanks. I had thought I had read somewhere that global recordsets and databases were declared using Dim but I'm obviously mistaken.

    Thanks for your help
    Marion

  7. #7
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    Technically, the "Public" keyword is DIM'ing a variable - just to the Public scope.
    DIM by itslef dimensions the variable to the scope of the procedure or function.

    tc

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by tcace
    Technically, the "Public" keyword is DIM'ing a variable - just to the Public scope.
    DIM by itslef dimensions the variable to the scope of the procedure or function.
    Or module if in the general declarations
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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