Results 1 to 8 of 8
  1. #1
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127

    How to Export a Form or Report as a "Package"


    Hi every one
    I have been trying to Export My main form and all related objects to a fresh new database. By Searching all over I found some information but it doesn't seem to work because I don't knoe how to run it right. This is the link http://bytes.com/topic/access/insigh...report-package
    I tried many ways writing the three codes as one module and calling it or writing the top one as a module and the other too on top of the buttons code window. Can some body please help me to do this. Export a form and all its related objects to a fresh new data base. please help
    Thank you

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    You pasted all the code in a general module?

    You changed the code to use drive path of your preference?

    Call the Procedure:

    Call PackageObject("your form or report object name", specify "Form" or "Report")

    Have you step debugged?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127

    Talking

    Hi Jun Thank you so much. I missed you. I Changed the Path to C:\Users\Shiham\Documents\AccessProjects. Projects is the folder where I want the new database to be. I Just changed all the paths in the first and last code to this same drive name and tried the code. I got the tables forms and queries But NOT the modules. does this code export only tables forms and reports. Not modules and macros. Thank you very much for helping. Please explain Or Is it possible for us to modify it so that it would export all the related objects including the module macros too. Thank you

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Are saying this does not bring over the code behind forms?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    1. Thanks for commin back june. Well actually All the codes behind the forms are there. the recordset quaries and tables are also there. But one form was missing that was supposed to open with in a code. Could be because the module I was using was to stop the execution of the runnin code in the main form that opens an attachment file in windows media player. the execution is Paused till the player loads fully so it can take screen shot of the vedio and save as its cover. the form that was not exported is supposed to open at the end after the execution. after the plater loads. Its name is screen shot. A one inch form with one button to take the shot. So I imported the module and it did not work. the stop execution line is yellow. so I unmarked and it warned that tha form is not there so I imported it it. over all it seems ok. May be there is some error with the codes execution part that's why the module and the form that's opening after the execution was skiped from the export. But I compiled befor export and no error was there. here is the code behind that form please see if it looks okay see the part Public Sub ExecCmd(cmdline As String). so Is it this code or the filepath naming. that skiped this module and the form?
      Because in the Exporting code
      the folders are shown as different. But I gave the same path for both lines. Did I do right?
      DoCmd.TransferDatabase acExport, "Microsoft Access", "F:\PRISM\PRISM Support Programs\Development\dbExport_" & Format(Date, "yyyy-mm-

    C:\Users\Shiham\Documents\AccessProjects\dbExport *-----------------------------

    1. dd") & ".accdb", acForm, strName, strName
    2. ElseIf lngType = -32764 Then
    3. DoCmd.TransferDatabase acExport, "Microsoft Access", "F:\MyDatabases\dbExport_" & Form
    4. C:\Users\Shiham\Documents\AccessProjects\dbExport *--------------------------------------

    After exporting the module it showed error on the execcmd line yellow.
    1. Here is the code in my main form that refer to the module and form that are suppose to be related objects Thank you june

    Code:
    Private Sub AddFile_Click()
    
    With Application.FileDialog(msoFileDialogFilePicker)
        .AllowMultiSelect = True   'Adjust the File Picker to allow multiple files to be selected
        .Title = "Locate a file to attach"
        .ButtonName = "Choose"
        .Filters.Clear
        .Filters.Add "All Files", "*.*"
        .InitialFileName = "C:\"
        .InitialView = msoFileDialogViewThumbnail
        
            If .Show = 0 Then
            Exit Sub
            End If
        
            'We will look for multiple files selected by the user
            Dim varFile As Variant
                'Dim varFile As Variant
                Dim rst As DAO.Recordset
                Const strTable = "Table1"
                Const strField = "Files"
                Set rst = CurrentDb.OpenRecordset(strTable)
                For Each varFile In .SelectedItems
                'You can view the debug results in the immediate window (Keyboard shortcut Ctrl+G)
                Debug.Print varFile 'You will have to nest your code block(s) here (before NEXT) to attach each file
                '-----------------------------------------------------------------------
                rst.AddNew
                'rst!Last = Me.Id '
                AddAttachment rst, strField, varFile
                rst!FPathName = varFile
                'Me.FPathName
                rst.Update
                rst.MoveLast
                
                '----------------------------------------------------------------------------
                Next
    rst.MoveLast
    'Now we can clean up the DAO object
    rst.close
    Set rst = Nothing
    End With
    '======================
    DoCmd.Requery "FilePhotoSearcgFr"
    DoCmd.Requery "tbl1Files11Data"
    Me.Requery
    DoCmd.GoToRecord , , acLast
    '------------------------------------------
    Dim strFilePath
    With Me.RecordsetClone
    .Bookmark = Me.Bookmark
    strFilePath = "C:\Temp\" & Me.tbxFileName
    If Dir(strFilePath) <> "" Then VBA.Kill strFilePath
    ![Table1.Files.FileData].SaveToFile strFilePath
    ExecCmd "VBA.Shell"      ' the module
    VBA.Shell "Explorer.exe " & Chr(34) & strFilePath & Chr(34), vbNormalFocus
    '================================================
    
    'MsgBox "Process Finished"
    End With
    'MsgBox "Process Finished"
    '==================================
    DoCmd.OpenForm "TakeScreenshot", acNormal 'The form

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    If the code brings over related objects and their code, then sounds like it does what was designed to.

    I don't think Access documents a relationship between objects and general modules/macros nor would it know that code behind an object calls another object. But then I don't really know how Access determines object relationships anyway. Maybe it's where tables are in common use in RecordSource.

    Regardless, I don't have any new answers for you and figuring out this code might require more time than I want to dedicate.

    Why do you need it?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    Thanks for skating back. I guess you are right. I need it not mainly for this attachment data base. Its just for fun. But I need it for my main database. Its pretty very complicated and clattered. when I started I had no knowledge of vba. I was writing and mainly inventory. Its clattered with too many objects macros modules and forms. I have my inventory and and issues and assets and some other stuff. Now I want to simplify it cause I know a little more vba. But when I try to do it manually it gets very complicated and some functions will not work. cause it was not made with the end in mind. But this packaging form is promising and it will make my task easy. But If we can make It work like take all realated objects I think it will be very helpful and a need for beginners like us. thank you very much for making this work for me and in the future If you find a complete solution It would be wonderful.

  8. #8
    aspen is offline Competent Performer
    Windows Vista Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    127
    Thanks June. You are right. When we have all the main objects exported. its not difficult to get the missing ones and probably access lets you know the name of the missing object. Thanks for making the code work for me. This problem is solved.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 30
    Last Post: 09-27-2013, 01:34 PM
  2. Replies: 3
    Last Post: 04-15-2013, 07:09 AM
  3. Replies: 4
    Last Post: 02-13-2013, 02:35 PM
  4. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  5. Replies: 1
    Last Post: 08-23-2012, 08:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums