KP_SoCal
Board Regular
- Joined
- Nov 17, 2009
- Messages
- 116
I'm using a sub routine to import specified tables from other databases (see below). As you can see, I'm writing a lot of redundant lines of code. I'm sure I could simplify this with a function, but I'd really appreciate a little guidance on how to accomplish this. As always, thanks for any help.
P.S. On a side note, I'm also running another code that ensures each of the dataobjects listed below are deleted before linking them.
P.S. On a side note, I'm also running another code that ensures each of the dataobjects listed below are deleted before linking them.
Code:
Sub ImportAccessTables()
Fpath = Environ("USERPROFILE")
DoCmd.TransferDatabase TransferType:=acLink, _
DatabaseType:="Microsoft Access", _
DatabaseName:=Fpath & "\Documents\databases\CustomerMaster.accdb", _
ObjectType:=acTable, _
Source:="tblAllCustomers", _
Destination:="tblAllCustomers"
DoCmd.TransferDatabase TransferType:=acLink, _
DatabaseType:="Microsoft Access", _
DatabaseName:=Fpath & "\Desktop\Sources.accdb", _
ObjectType:=acTable, _
Source:="tblSources", _
Destination:="tblSources"
DoCmd.TransferDatabase TransferType:=acLink, _
DatabaseType:="Microsoft Access", _
DatabaseName:=Fpath & "\RawData.accdb", _
ObjectType:=acTable, _
Source:="tblRawData", _
Destination:="tblRawData"
End Sub
Last edited: