Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

copy to a:

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jean-Paul De Winter - 03 Mar 2005 10:22 GMT
Hi,
I would like to copy 1 table form my project to a diskette (a:) upon
clicking a pushbutton.
Then also, how to add the data form the a diskette into the table of
the current project.
All I need is the code..
Thanks
JP
Wayne Morgan - 03 Mar 2005 13:28 GMT
Here is a quick routine I've used to do just that. It's not as "pretty" as
it ought to be, but it works. This exports data to a new file created on a
floppy (A: drive).

Private Sub cmdExportLeaveInfo_Click()
On Error GoTo CheckError
'For the export to Excel, the needed date is SCD which is
'in the tblBUMs table. The tblBUTime table shouldn't
'be needed. This should work as already modified.
Dim msg As String, wrkDefault As DAO.Workspace, dbsNew As DAO.Database
Dim RetVal As Integer, qdf As DAO.QueryDef

'Check for a floppy in the A: drive then create an mdb
'file on the A: drive
msg = "The tables and queries needed for the primetime leave spreadsheet to
a database file on the A: drive."
msg = msg & vbCrLf & "If there is already a file named D10 Database.mdb it
will be replaced."
msg = msg & vbCrLf & "Insert a blank formatted disk into the A: drive and
click Ok when ready."
RetVal = MsgBox(msg, vbInformation + vbOKCancel, "Insert Floppy")
If RetVal = vbCancel Then Exit Sub

'No need to set these every try, so let's do it now.
Set wrkDefault = DBEngine.Workspaces(0)
TryAgain:
'Check on API calls to see if the drive is ready and insert it here
DoCmd.Hourglass True
If Dir("A:\D10 Database.mdb") <> "" Then Kill "A:\D10 Database.mdb"
Set dbsNew = wrkDefault.CreateDatabase("A:\D10 Database.mdb", _
       dbLangGeneral & ";pwd=secret stuff", dbVersion30)
'Export the needed tables and queries
DoCmd.TransferDatabase acExport, "Microsoft Access", "" & dbsNew.Name & "",
acTable, "tblBUMs", "tblBUMs", , True
DoCmd.TransferDatabase acExport, "Microsoft Access", "" & dbsNew.Name & "",
acTable, "tblTeam", "tblTeam", , True
DoCmd.TransferDatabase acExport, "Microsoft Access", "" & dbsNew.Name & "",
acTable, "tblBU", "tblBU", , True
'DoCmd.TransferDatabase acExport, "Microsoft Access", "" & dbsNew.Name & "",
acQuery, "qryPassToExcel", "qryPassToExcel", , True
'Can only export tables to earlier versions of mdb files
'so I have to create the query in the new database.
dbsNew.CreateQueryDef "qryPassToExcel",
CurrentDb.QueryDefs("qryPassToExcel").SQL

CleanUp:
DoCmd.Hourglass False
On Error Resume Next
dbsNew.Close
Set dbsNew = Nothing
Set wrkDefault = Nothing
Exit Sub

CheckError:
DoCmd.Hourglass False
'Error 52 is generated if no floppy is in the drive when doing a Dir
If Err.Number = 52 Then
   msg = "Please insert a formatted disk in the A: drive!" & vbCrLf &
"Click Ok when ready."
   RetVal = MsgBox(msg, vbCritical + vbOKCancel, "Insert Floppy")
   If RetVal = vbCancel Then Resume CleanUp
   Resume TryAgain
End If
If Err.Number = 3026 Then
   msg = "Disk is full! Please insert a floppy with at least 60k of empty
space."
   RetVal = MsgBox(msg, vbCritical + vbOKCancel, "Insert Floppy")
   If RetVal = vbCancel Then Resume CleanUp
   Resume TryAgain
End If
msg = "Error # " & Str(Err.Number) & " was generated by " _
           & Err.Source & Chr(13) & Err.Description
MsgBox msg, vbOKOnly + vbExclamation, "Error", Err.HelpFile, Err.HelpContext
Resume CleanUp

Signature

Wayne Morgan
MS Access MVP

> Hi,
> I would like to copy 1 table form my project to a diskette (a:) upon
[quoted text clipped - 4 lines]
> Thanks
> JP
anonymous@discussions.microsoft.com - 03 Mar 2005 13:46 GMT
hi
access table cannot exist on their own. you would have to
export it to another application like access or excel. to
do that you can use the tranfer db or transferspreadsheet
method. since you are using a disk i would recomend excel.

DoCmd.TransferSpreadsheet acExport,
8, "yourtable", "A:\yourfile.xls", True, ""

note: this wrapped. should be 1 line.

>-----Original Message-----
>Hi,
[quoted text clipped - 6 lines]
>JP
>.
Jean-Paul De WInter - 03 Mar 2005 15:49 GMT
the idea is that users copy their data from an access project to a disk,
bring this disk to me and I merge the data from the disk into the
"mother-table"
so no excel or whatever
see.....
Thanks
JP
> hi
> access table cannot exist on their own. you would have to
[quoted text clipped - 19 lines]
> >JP
> >.
SusanV - 03 Mar 2005 16:43 GMT
You can do an append query from a linked excel file same as an imported or
linked table...

> the idea is that users copy their data from an access project to a disk,
> bring this disk to me and I merge the data from the disk into the
[quoted text clipped - 26 lines]
>> >JP
>> >.
anonymous@discussions.microsoft.com - 03 Mar 2005 17:50 GMT
hi again,
you can upload from excel. what i am saying is that you
must export to some sort of application and excel would
most probable take up the least amount of space on the
disk. unless you want to use notepad.

>-----Original Message-----
>the idea is that users copy their data from an access project to a disk,
[quoted text clipped - 29 lines]
>
>.
Jean-Paul De WInter - 03 Mar 2005 18:36 GMT
sorry all... but I don't want the data to be in excel...
This is the idea.

I created a project for the school I work in. It all has to do with monthly
reports.
Now all teachers must enter students results into one computer where the
project runs on.
It would be nice to give all teachers this project to run on their own
computers at home. All they have to do is copy the results onto a disk, give
it to me and I "merge" everything into the schools computer.... see, that
simple (BG)

Thanks for your help
JP

> hi again,
> you can upload from excel. what i am saying is that you
[quoted text clipped - 41 lines]
> >
> >.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.