Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Return Primary Key

Hey there

I have an access db with multiple tables linked together with primary keys.
I need to populate this db from excel. Is it possible to upload a record to a
parent table, have the primary key for that record returned, and then used
when uploading records to the child tables.

I am fairly new at working with VBA, and any help would be highly appreciated.

Regards


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Return Primary Key

Lasca,
There are lots of ways to do this but this works well.

Create an Interface table in Access that contains all the necessary
columns for each of the parent and child tables.
Create a query that will append this data to the tables.
Create a macro that will run the query. You also need to mark the
rows as processed in the Interface table after running the append
query.

In Excel create a Worksheet in the same format as the Interface table
in Access.
Populate the Excel worksheet
Link the Access database to this Excel Worksheet

Run the query to import the records into the Access Interface Table
either from Access or Excel. Importing the data into the Interface
table allows to do final data integrity checks before loading the data
into your production tables.
Do Data Integrity checks
Load Produciton Tables
You will need the Macro if running from Excel

All records in the Excel Worksheet and the Interface table must be
marked as processed so they can not be imported again and again and
again.

code to run an Access Query from Excel

Sub RunAccessQuery()
Dim appAccess As Access.Application
Set appAccess = New Access.Application
appAccess.Visible = True
appAccess.DoCmd.SetWarnings False
appAccess.OpenAccessProject ("C:\Test.mdb")
appAccess.DoCmd.RunMacro ("MacroToImportRecords")
appAccess.DoCmd.SetWarnings True
appAccess.Quit
Set appAccess = Nothing
End Sub

Goshute
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recordset with Primary Key Adax Excel Programming 2 October 6th 09 10:33 PM
Generating a primary key Access::Student Excel Discussion (Misc queries) 7 July 1st 09 11:07 PM
(Primary) Key Column? Rebecca Excel Discussion (Misc queries) 5 September 21st 08 05:14 PM
PRIMARY KEYS Brent Excel Programming 0 April 11th 07 05:34 PM
Check for Primary Key BillyRogers Excel Programming 2 September 20th 06 06:06 PM


All times are GMT +1. The time now is 09:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"