|
-
May 11th, 2007, 02:23 PM
#1
Thread Starter
Member
[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.
-
May 13th, 2007, 12:31 AM
#2
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
May 16th, 2007, 09:10 AM
#3
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|