Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

transfer table programmatically

Posted on 2012-03-28
2
Medium Priority
?
405 Views
Last Modified: 2012-03-28
I need to send a table that is sent to us daily to an archive when we are through with it.
The name of the table is something like PRWBBEPI_****. The last 4 digits will be different. Can i use a wild card in the function and if so, how? Thanks for any help



Public Function Send2Archive()

 DoCmd.TransferDatabase transfertype:=acExport, _
  databasetype:="Microsoft Access", _
  databasename:="C:\Documents and Settings\Leidago\My Documents\destination.mdb", _
  ObjectType:=acTable, Source:="users", _
  Destination:="userstbl", structureonly:=False
 
 
End Function
0
Comment
Question by:Serena2345
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 37778035
do you have more than one table that starts with "PRWBBEPI_" ?

dim td as dao.tabledef, db as dao.database, sTable as string
set db=currentdb

for each td in db.tabledefs
        if left(td.name,9)="PRWBBEPI_" then
            sTable=td.name

            msgbox sTable

           
            Send2Archive stable
next


you can change your function to accept variable names

Public Function Send2Archive(strTable as string)

 DoCmd.TransferDatabase transfertype:=acExport, _
  databasetype:="Microsoft Access", _
  databasename:="C:\Documents and Settings\Leidago\My Documents\destination.mdb", _
  ObjectType:=acTable, Source:=strTable, _
  Destination:=strTable, structureonly:=False
 
 
End Function
0
 

Author Comment

by:Serena2345
ID: 37778183
There is a table called PRWBBEPI" but no "_" so your suggestion should work. As always Cappie Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question