Results 1 to 12 of 12
  1. #1
    Join Date
    Oct 2003
    Location
    Newport, RI
    Posts
    6

    Unanswered: FindRecord isn't available now?

    In VBA, I've created a record as a result of an operator action. When I try to display that record in the current form using FindRecord, I get the following error:
    Error Number: 2046, the command or action 'FindRecord' isn't available now.

    I've tried Me.Requery before doing the FindRecord but it makes no difference. If I close the form and then reopen it, I'm able to display the new record with no problem. Does anyone know what I am doing wrong?

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Is the form's property set to DataEntry = Yes?
    Last edited by pkstormy; 08-03-07 at 19:06.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Oct 2003
    Location
    Newport, RI
    Posts
    6
    Yes, I had the focus set to the a key field before doing the findrecord.

    Just before I received your reply, I was working on some code for a button on the same form and the problem went away. I wish I knew what I did to fix it.

    Thanks anyway.

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Sorry I was editing the last post. Did you check the Data Entry property of the form?
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Also, is the field you're searching on available to get the focus (ie. is it locked or not enabled?)
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Actually, it shouldn't matter if it's locked.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  7. #7
    Join Date
    Oct 2003
    Location
    Newport, RI
    Posts
    6
    The form DataEntry property is set to No. It still is set to no and seems to be working fine. The field that requires focus is locked and enabled.
    Last edited by rogerb1221; 08-03-07 at 19:19.

  8. #8
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    ok...I've encountered this in the past but someone will probably beat me to the answer. I'll check when I get home after work and if no one's beat me to the answer, I'll hopefully have thought of it by then.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  9. #9
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Don't you just hate it when it does that? I'm a little hazy where you said:
    I've created a record as a result of an operator action. When I try to display that record in the current form using FindRecord, I get the following error:
    Exactly how is this record created? And more importantly, I think, had the record been saved at the point in time when you attempted the FindRecord?
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  10. #10
    Join Date
    Oct 2003
    Location
    Newport, RI
    Posts
    6
    Missingling,
    I have a button on a form that when selected, will generate a new record. I create the new record by opening a recordset and running the .AddNew method. I also calculate some initial values for some of the fields. After I did an .update, I tried make the current record = the new record by doing a FindRecord. That is when the error appeared. The problem is fixed now but I don't know what I did to fix it.

  11. #11
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    As John Walton used to say "Life's a mystery!"
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  12. #12
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Just out of curiousity, Are you doing anything like this for the button to add a new record?
    .....
    rs.addnew
    rs!Something = something
    rs!SomethingElse = somethingelse
    rs.update
    dim CID as variant (or long)
    CID = rs!MyRecIDField
    me.MyRecIDField.setfocus
    docmd.FindRecord CID
    rs.close
    set rs = nothing
    or
    .....
    rs.addnew
    rs!Something = something
    rs!SomethingElse = somethingelse
    rs.update
    dim CID as variant (or long)
    CID = rs!MyRecIDField
    me.MyRecIDField.setfocus
    me.MyRecIDField.requery <- if MyRecIDField is perhaps a combobox on the form.
    or
    Refresh <- to refresh the form
    or
    me.requery <- to requery the form's recordset
    docmd.FindRecord CID
    rs.close
    set rs = nothing


    I'm surprised that just the docmd.gotorecord,,acnewrec doesn't take you to the new record. Is this an unbound form where some of the fields are bound?
    Last edited by pkstormy; 08-03-07 at 23:30.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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