473,804 Members | 3,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need help with importing a Table from another access database in code

I have code to allow the user to select any .mdb of his choice on the HD,
but how do I then let him select a table from within this .mdb and then
create a destination table of a name that I assign in code.

DoCmd.TransferD atabase acImport, "Microsoft Access", anymdb, acTable,
anychoicetable, "fixedtablename "

So I would like this command to prompt the user so the user can select the
table
Thanks in advance
Nov 12 '05 #1
3 1898
Danny,

Look at TableDef in the help file. You will need to use the TableDef collection
to get a list of the tables in the .mdb. You will then have to write some code
where the user can select the table name from the collection and assign it to a
string variable such as SelectedTbl. Then in your TransferDatabas e expression,
you will put SelectedTbl where you have anychoicetable.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdata sheet.com
www.pcdatasheet.com
"Danny" <da********@hot mail.com> wrote in message
news:D2******** **************@ news4.srv.hcvln y.cv.net...
I have code to allow the user to select any .mdb of his choice on the HD,
but how do I then let him select a table from within this .mdb and then
create a destination table of a name that I assign in code.

DoCmd.TransferD atabase acImport, "Microsoft Access", anymdb, acTable,
anychoicetable, "fixedtablename "

So I would like this command to prompt the user so the user can select the
table
Thanks in advance

Nov 12 '05 #2
Danny,

Here's some code by Joe Black I just found in another newsgroup. It's almost
exactly what you need!

Steve
PC Datasheet

I use the following code to populate a combo box with the table names in the
current database (excluding system tables):

'*** code start ***
Private Sub Form_Open(Cance l As Integer)
Dim strRowSource As String
Dim TblDef As TableDef

Set db = CurrentDb
For Each TblDef In db.TableDefs
If InStr(TblDef.na me, "Sys") = 0 Then
strRowSource = strRowSource & "'" & TblDef.name & "';"
End If
Next
strRowSource = Left(strRowSour ce, Len(strRowSourc e) - 1)
cboTableDefs.Ro wSource = strRowSource

Set db = Nothing
End Sub
'*** code end ***

and when I select a table name from the combo box, the following code puts
all the field names from the selected table into a listbox:

'*** code start ***
Private Sub cboTableDefs_Af terUpdate()
Dim Feeld As Field
Dim strRowSource As String

If IsNull(cboTable Defs) Then Exit Sub

Set TblDef = db.TableDefs(cb oTableDefs)
For Each Feeld In TblDef.Fields
strRowSource = strRowSource & "'" & Feeld.name & "';"
Next
strRowSource = Left(strRowSour ce, Len(strRowSourc e) - 1)
lstFields.RowSo urce = strRowSource
lstFields.Reque ry
End Sub
'*** code end ***

"Danny" <da********@hot mail.com> wrote in message
news:D2******** **************@ news4.srv.hcvln y.cv.net...
I have code to allow the user to select any .mdb of his choice on the HD,
but how do I then let him select a table from within this .mdb and then
create a destination table of a name that I assign in code.

DoCmd.TransferD atabase acImport, "Microsoft Access", anymdb, acTable,
anychoicetable, "fixedtablename "

So I would like this command to prompt the user so the user can select the
table
Thanks in advance

Nov 12 '05 #3

"PC Datasheet" <sp**@nospam.sp am> wrote in message
news:wz******** ******@newsread 2.news.atl.eart hlink.net...
Danny,

Here's some code by Joe Black I just found in another newsgroup. It's almost exactly what you need!

Steve
PC Datasheet

I use the following code to populate a combo box with the table names in the current database (excluding system tables):

'*** code start ***
Private Sub Form_Open(Cance l As Integer)
Dim strRowSource As String
Dim TblDef As TableDef

Set db = CurrentDb
For Each TblDef In db.TableDefs
If InStr(TblDef.na me, "Sys") = 0 Then
strRowSource = strRowSource & "'" & TblDef.name & "';"
End If
Next
strRowSource = Left(strRowSour ce, Len(strRowSourc e) - 1)
cboTableDefs.Ro wSource = strRowSource

Set db = Nothing
End Sub
'*** code end ***

and when I select a table name from the combo box, the following code puts
all the field names from the selected table into a listbox:

'*** code start ***
Private Sub cboTableDefs_Af terUpdate()
Dim Feeld As Field
Dim strRowSource As String

If IsNull(cboTable Defs) Then Exit Sub

Set TblDef = db.TableDefs(cb oTableDefs)
For Each Feeld In TblDef.Fields
strRowSource = strRowSource & "'" & Feeld.name & "';"
Next
strRowSource = Left(strRowSour ce, Len(strRowSourc e) - 1)
lstFields.RowSo urce = strRowSource
lstFields.Reque ry
End Sub
'*** code end ***

"Danny" <da********@hot mail.com> wrote in message
news:D2******** **************@ news4.srv.hcvln y.cv.net...
I have code to allow the user to select any .mdb of his choice on the HD, but how do I then let him select a table from within this .mdb and then
create a destination table of a name that I assign in code.

DoCmd.TransferD atabase acImport, "Microsoft Access", anymdb, acTable,
anychoicetable, "fixedtablename "

So I would like this command to prompt the user so the user can select the table
Thanks in advance



Thakns, this is great.

I will apply this my app.

Danny

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4963
by: Howard | last post by:
I am trying to use DoCmd.TranferSpreadsheet to import a spreadsheet into an Access table that's not the CurrentDB. I have the database open, but I don't see how to tell the TransferSpreadsheet command that the table is not in the CurrentDB. Is there a way to specify a filename and table within the table string of the TransferSpreadsheet command? Is there a way of temporarily changing the CurrentDB to be the other database so the...
9
4037
by: Edward S | last post by:
I budget for a Project in an Excel sheet as illustrated below. The months below are usually a 2 year period i.e. 24 months, though it could be over 24 months depending upon a Project. I then need to input this in an Access database, where I do a comparison with the Actual cost. The table “TblBudget” in Access is made of 4 fields, namely: (1) CostElement (2) CostCenter (3) Month (4) Amount$. At the moment this method is very cumbersome....
1
1382
by: Serious_Practitioner | last post by:
Good day - As you suggested, I got and used the right version of Jetcomp, and I also tried to run compact and repair a couple of times. I think that the compact and repair process doesn't fully complete - there's a little progress bar in the lower left area of the status bar that gets about halfway done, and then stalls. It doesn't keep me from closing the database, it just stops. So that seems to be out. Similarly Jetcomp, which seemed...
3
298
by: Danny | last post by:
I have code to allow the user to select any .mdb of his choice on the HD, but how do I then let him select a table from within this .mdb and then create a destination table of a name that I assign in code. DoCmd.TransferDatabase acImport, "Microsoft Access", anymdb, acTable, anychoicetable, "fixedtablename" So I would like this command to prompt the user so the user can select the
9
1718
by: cheryl | last post by:
I am relatively new to programming in Access for a multi user environment, and am having trouble figuring out if there is a way to accomplish one of our user requests. I am working on a multi user Access 2002 application. BE db resides on a LAN, FE on each client. The app imports large .csv files containing billing info by date and allows users to run various reports. At a given time, one user may be importing a file into the main...
3
1728
by: pemigh | last post by:
A while back I imported tables to a new database via Files-->Get External Data --> Import... All was well for several months, and then the database started behaving badly in a couple of ways, including slow (actually speed was fine when users opened database, then deteriorated after a few minutes of normal use) and errors when trying to enter data. Specifically, this appears when entering data in a subform, even when an individual is...
1
5166
by: thadson | last post by:
Hi, I'm trying to import specific cells from MS Excel 2000 spreadsheets to MS Access 2000 tables then move the spreadsheets to a different directory. I'm very new to this and I'm having trouble to implement this. I have worked out so far the code to import certain cells into 1 table, but I do not know how to import some other cells into another tables so the data would be connected and remain together. So lets say that I have 2 tables...
16
3526
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate (tried a groups query, but "count" won't work), then do an update query to change the duplicate to...
0
1629
by: upadhyayanuj | last post by:
Hi I have an error while uploading file and then importing it into my sql table The process cannot access the file 'c:\inetpub\wwwroot\FlowLine\Excel File\Fan_Details.xls' because it is being used by another process Now Some times its run successfully, i don't no how but somtimes it gives error, I figure out there is security issue of the folder where its storing the file, But i had given all right to user there
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9587
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7623
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.