Results 1 to 4 of 4
  1. #1
    BallinWallin is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    11

    How to Set Focus to a Record and Using FindFirst

    If you are here to answer questions, thank you for taking the time to read mine.

    The basic operation is my form searches through a table for any record whose targeted field matches a value input by the user. If one exists, several text boxes on the form are populated with other fields from that record. That all works fine.

    The problem occurs when I change or add to the text boxes and call my update sub. For some reason, the update overwrites the first record in my table instead of the one that (I thought) had focus. The code that searches through the table to find the record of interest exits as soon as it has found the right one, and the update procedure that is subsequently called doesn't have any table navigation commands so I don't understand why the focus is not still on the record of interest where I left it.

    I tried to remedy the situation with the FindFirst command thinking that maybe exiting the sub caused some sort of focus reset. So I created a public integer variable and it is set equal to the AutoNumber ID field when the correct record is found but that didn't work. When the update sub is run and the FindFirst line executes I get run-time error 3070 saying "...database engine does not recognize LoadedRecord (the variable name) as a valid field name or expression." I'm sure I'm not using the FindFirst method correctly and I'm unable to find an explanation of its syntax online, so could someone please explain it in painful detail for me? And is there perhaps a better way for me to do this rather than using FindFirst at all.



    .FindFirst "[ID] = LoadedRecord"

    I would be happy to post more or all of my code but I didn't want to make this too lengthy. Thank you very much for your time and help.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Can you post the code in your sub procedure that is giving you unexpected results?

    As for
    .FindFirst "[ID] = LoadedRecord"

    Maybe
    .FindFirst "[ID] = " & LoadedRecord

  3. #3
    BallinWallin is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    11
    Hahaha, always so simple. Thank you very much. It works now but I would be happy to post my code anyway if you think it would help someone else.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Yes, post your code. I still do not fully understand your question and how it relates to the symptom. All I understand at this point is you were able to employ the .FindFirst method successfully. There may be a more direct or eloquent approach.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to have Page Tabs focus on record.
    By Greycom4 in forum Forms
    Replies: 5
    Last Post: 12-19-2013, 08:00 AM
  2. .FindFirst problem
    By akhmadahdiyat in forum Programming
    Replies: 2
    Last Post: 11-29-2013, 12:27 AM
  3. Replies: 2
    Last Post: 11-01-2013, 09:57 AM
  4. Replies: 3
    Last Post: 01-19-2013, 01:37 PM
  5. Using FindFirst code
    By saltydawg617 in forum Access
    Replies: 2
    Last Post: 07-29-2011, 05:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums