If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Appending records from table in another database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-19-12, 20:05
san134 san134 is offline
Registered User
 
Join Date: Jan 2012
Posts: 1
Appending records from table in another database

Hi

I recently started using access database. I have created a database which have few forms and tables. This database will be used in field (at different locations) to collect the data. After certain period of time I need to combine data from all these different locations and put in one single 'Master' database. This process will be done on routine basis.

I want to create a form in this Master database where user can browse and select these other (field ) databases and import into master database. As the process will be repeated I want to avoid copying duplicate records which already exist in master database.

I know very little about vb/sql coding , however I have managed to create a list box and button which can be used to browse and select the file. After selecting the file, the path is stored in list box.

Here is the code :

Private Sub Command2_Click()

Dim fDialog As Office.FileDialog
Dim varFile As Variant

' Clear listbox contents. '
Me.List3.RowSource = ""

' Set up the File Dialog. '
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

With fDialog

' Allow user to make multiple selections in dialog box '
.AllowMultiSelect = False

' Set the title of the dialog box. '
.Title = "Please select one or more files"

' Clear out the current filters, and add our own.'
.Filters.Clear
.Filters.Add "Access Databases", "*.ACCDB"
.Filters.Add "All Files", "*.*"

' Show the dialog box. If the .Show method returns True, the '
' user picked at least one file. If the .Show method returns '
' False, the user clicked Cancel. '
If .Show = True Then

'Loop through each file selected and add it to our list box. '
For Each varFile In .SelectedItems
Me.List3.AddItem varFile
Next

Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub




I tried searching really hard on the internet but I was unable to find how to write code to import specific table from that selected database to master database. I would appreciate if some of experts would give me a direction about how to go from here...

Thanks in advance..
Reply With Quote
  #2 (permalink)  
Old 01-20-12, 06:17
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
You can specify an external database in the SELECT part of an append query:
Code:
INSERT INTO Tbl_Databases (Server, DbName, Owner)
SELECT Server, DbName, Owner 
FROM Tbl_Databases IN 'C:\Documents and Settings\Sinndho\My documents\Access\SandBox64.mdb'
__________________
Have a nice day!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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