Results 1 to 7 of 7
  1. #1
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209

    Auto Export Form

    I am trying to set it up to where I place a button on my main form, and it will export a different form whose name would be input in a textbox (name of textbox is ReferenceNum) on the main form.

    I am trying this code, but am not quite sure how to completely fill it out. I think what this code is saying is Transfer Database, Export, Microsoft Access is the data type, exporting a form, and now is where my trouble comes in because the name of the form I want to export is based on the value of ReferenceNum, and I am not sure how to write this? and then the last portion would be to export to this location

    DoCmd.TransferDatabase acExport, "Microsoft Access", acForm, (I want to set this to the value of a textbox on my main form...so it would say something similar to = Me.ReferenceNum), C:\test\test.mdb,

    This is the full code I Tried and it tells me Syntax error
    Code:
    DoCmd.TransferDatabase(acExport, , , acForm, Me.CustNo, "C:\test\test.mdb", No)
    First and foremost, can someone provide me with the code to export the form named what is input into the textbox

    Secondly can someone verify that is the correct code to automate export the form, and if it is not can someone tweak the code to make ensure it does the requested process.

    Thanks in advance to all who are kind enough to help.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Try:

    DoCmd.TransferDatabase acExport, "Microsoft Access" , "C:\test\test.mdb", acForm, Me.CustNo, "destination table name", No
    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
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209
    I do not want to input the "destination table name" I want that to be what is input in Me.CustNo as well, is there a way that I can have it automatically name the form that is being exported to the value of Me.CustNo. Or is there a way to set it to name the table that is exported the same name as what the original table name is? Example, in the main db its named Test1 can the code say something like "Destination name = Me.CustNo" and that way regardless of what the table name is it will always keep the original name./

    Would it be easier If I changed this to a module, would I just input the above code into my module, save the module as module1 and then add in the onclick event module1?
    Last edited by Juan4412; 07-13-2011 at 12:05 PM.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Sorry, should have been "destination form name". If you want the same name then repeat the input.

    DoCmd.TransferDatabase acExport, "Microsoft Access" , "C:\test\test.mdb", acForm, Me.CustNo, Me.CustNo

    Don't think the No argument is meaningful because not exporting table but shouldn't hurt as No is the default.

    Don't see any reason to put in a general module unless you want to call the procedure from several locations.

    Check this article http://www.blueclaw-db.com/transferdatabase-docmd.htm
    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
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    The easiest way is to put this code (from the link) into a standard module:

    http://www.btabdevelopment.com/ts/de...aspx?PageId=47

    and then call it, passing the name of the form you want exported (and make sure it is open at the time).

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    In my test, object targeted for export did not have to be open. The code did error if the destination database was open.
    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
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Okay, I just read this through again and now I'm not sure what the OP is asking for. Are you wanting to basically transfer a form (not the data, but the form itself) into another database? My response was for someone who wanted to export the DATA from a form, not the form itself. But the first post is not fully clear as to which is wanted (sometimes someone may select something thinking it does one thing when they want another).

    So Juan - can you clarify exactly what you are looking to do? Are you looking to place the actual form into another database or are you wanting to export the DATA from the records that are displayed in the form when it is open?

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

Similar Threads

  1. Replies: 63
    Last Post: 01-25-2013, 05:20 AM
  2. Export single record from a form to PDF
    By GraemeG in forum Programming
    Replies: 1
    Last Post: 04-10-2011, 01:33 PM
  3. Crosstab and Export Form example
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-24-2010, 12:30 AM
  4. Export Form but Keep Information?
    By SpeedyApocalypse in forum Forms
    Replies: 4
    Last Post: 04-09-2010, 07:30 AM
  5. Export Command Button in Form
    By jjmartinson in forum Forms
    Replies: 3
    Last Post: 08-25-2009, 01:28 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