Results 1 to 6 of 6
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Recordset search for ID then obtain column information about that row

    I'm doing a recordset in vba and I'd like to seek a specific ID then return into some variables the column values of that particular row



    so I look for the ID

    then I get the rs!name and stuff that into a dim

    rs!name

    I've found rs.findfirst = "ID=" & lngNumber

    works however I don't know how to get the other fields once found

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Rather than open the recordset on the entire table, I'd open it on an SQL statement that only returned the desired row:

    "SELECT * FROM TableName WHERE ID=" & lngNumber
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,642
    What do you mean by 'get the other fields'? Don't you know the field names?

    Like this https://www.accessforums.net/program...orm-45725.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    What do you mean by 'get the other fields'? Don't you know the field names?

    Like this https://www.accessforums.net/program...orm-45725.html
    Say it is row 125 (or ID 125)

    then I want 125's rs!FirstName, rs!Surname, rs!address

    etc

    so say it finds row 5 and then I can obtain all the data from those fields

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by pbaldy View Post
    Rather than open the recordset on the entire table, I'd open it on an SQL statement that only returned the desired row:

    "SELECT * FROM TableName WHERE ID=" & lngNumber
    Yeah I thought about that - I might do that anyway.

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Nevermind - I see what I am doing wrong in my code.

    Putting in the wrong variables....

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

Similar Threads

  1. adding new column to recordset
    By pradeep.sands in forum Forms
    Replies: 10
    Last Post: 07-09-2013, 11:53 AM
  2. Replies: 4
    Last Post: 02-03-2013, 11:51 AM
  3. Replies: 19
    Last Post: 11-01-2012, 08:03 AM
  4. Skip column in recordset
    By jgelpi16 in forum Programming
    Replies: 5
    Last Post: 02-28-2011, 12:14 PM
  5. Recordset Search
    By ColPat in forum Programming
    Replies: 2
    Last Post: 08-14-2010, 08:25 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