Results 1 to 3 of 3

Thread: [resolved] searching in access tables

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    32

    [resolved] searching in access tables

    I know this should be easyb tu I just can't seem to get it right. I am trying to take information from one table and update another table with it, what is getting me is the seek function, or how to pinpoint the location of entry to be update.
    Code:
    Dim db As Database
    Dim WellInfo As Recordset, PluggedInputTable As Recordset
    Dim currentWell As String, SQLt As String
    Set db = CurrentDb
    Set WellInfo = db.OpenRecordset("WellInfo")
    SQLt = "SELECT * FROM PLUGGEDINPUTTABLE ORDER BY PLUGGEDINPUTTABLE!WellId;"
    Set PluggedInputTable = db.OpenRecordset(SQLt)
    PluggedInputTable.MoveFirst
    Do Until PluggedInputTable.EOF
        currentWell = PluggedInputTable!WellID
        
       varbookmark = .Bookmark
       ' WellInfo.Find (WellID = currentWell)
    Last edited by brellis1; May 16th, 2007 at 09:03 AM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: searching in access tables

    It sounds like you are going about this the wrong way.

    All you have to do is execute a SQL statement to update one tables record with the values of the other tables record you retrieve with a subquery.

    Something like...

    (Ima bit rusty with the sql code but maybe someone else can polish it up.

    Code:
    UPDATE Table1 SET Field1 = (SELECT Fieldx FROM Table2 WHERE SomeField = 'SomeValue')
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    32

    Re: [resolved] searching in access tables

    in case anyone is interested here was the final code i used...it updates two fields from one table to another (the master table has many more fields) the table to be updated is WellInfo. The table with the updating information is PluggedInputTable
    Code:
    UPDATE PluggedInputTable INNER JOIN WellInfo ON PluggedInputTable.WellID = WellInfo.WellID SET WellInfo.DatePlugged = [PluggedInputTable].[DatePlugged], WellInfo.[Current Status] = [PluggedInputTable].[Status]
    WHERE ((([WellInfo.WellID])=[PluggedInputTable.WellID]));

Posting Permissions

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



Click Here to Expand Forum to Full Width