Results 1 to 8 of 8
  1. #1
    driftking is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    4

    exporting each field of my access database to an excel by with different format

    hello,



    need help about an issue.

    i actually have an ms access database with the following format(assuming)

    title1 title2 title3 title4 title5 title6
    1a 1b 1c 1d 1e 1f
    2b 2b 2c 2d 2e 2f
    3a 3b 3c 3d 3e 3f
    4a 4b 4c 4d 4e 4f


    for each row in the ms access database above i need to retrieve an excel in the format below

    title1 1a
    title2 1b
    title3 1c
    title4 1d
    title5 1e
    title6 1f


    title1 2a
    title2 2b
    title3 2c
    title4 2d
    title5 2e
    title6 2f


    and so on....

    Any suggestion from where i can proceed,what tool can i use??

    thanks in advance

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Your details are very sketchy, and assuming this is exactly how your table is set up (there aren't any primary key fields etc) I would tend to create a module and export everything to a .csv.

    Assuming your table name is tblMatrix I'd do something like this

    Code:
    Dim fs
    Dim fsExportFile
    Dim sExportString As String
    Dim db As Database
    Dim rst As Recordset
    Dim fld As Field
    
    Set fs = CreateObject("scripting.filesystemobject")
    Set fsExportFile = fs.createtextfile("c:\test\testexport.csv", True)
    
    Set db = CurrentDb
    Set rst = db.OpenRecordset("SELECT * FROM tblMatrix")
    
    rst.MoveFirst
    Do While rst.EOF <> True
        For Each fld In rst.Fields
            sExportString = fld.Name & "," & fld.Value
            fsExportFile.writeline sExportString
        Next
    
        rst.MoveNext
    Loop
    
    Set db = Nothing

  3. #3
    driftking is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    4
    hello thanks for the reply. i have put diagrams for viewer to understand the issue easily.

    I am not used to ms access db,but have some experience with vb.net codes. i am eager to learn coding in access,can you tell me where to place the code in my database and send me good links from where i can start code in ms access database(i already know the basic,that is how to create table and add data manually).

    currently i have created an ms access database and added some data in it but do not know where to put your codes.

    Thanks in advance.

    ps: i use ms access 2010

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you can put it any number of places you can put it in the ON CLICK event of a button, you can make a module to run it manually, you can attach it any place you are currently running code, I do not know your database, the scope of your matrix table or anything else about your database so where you put it is up to you, the easiest thing to start with is to make a module (an option under the macros ribbon set) dump in the code in a sub main() function change the code to match your database and see if it gives you the results you want, where you go from there is up to you.

  5. #5
    driftking is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    4

    form to export ms access database to excel

    Alright,
    i reform my question(now that myself have understand the issue clearly ).

    i have an access database with a table containing data.
    assuming i have 100s of rows in it.
    What i want to do is for each row in the table i want to generate an excel sheet with specific fields in the database match specific cell in the excel template(please find attached).

    That is if i have 1 hundred rows in my access database....i have to generate 100 excel sheet and rename it automatically with 1 of the field in my database(find an example attached)

    i was thinking of making a form in ms access with button in it. on_click (event) it must loop through the database rows and generate excels according to the number of rows.

    can you suggest me a solution or how can i realise my idea

    ps: i have never work with access form before

    attachment
    1 ms access(contactDB) : from which i have to extract data
    1 excel(<NOM DU CONTACT>the field name from the ms access db): the template
    Attached Files Attached Files

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    contacts_DB-Modified.zip

    Here's a copy of your database back, I've added a module. In order for the module to work the database and the blank customer contact file (Customer_Blank.xls) must be in the same folder.

    Basically what this does is reads through your contacts table, for each item it finds it opens your 'template' file, fills in the appropriate information, then saves the template file with a new name in the same folder the database resides. I've only put in a couple of the fields to show you how to work it, from there you can do whatever you want/add whatever you want in terms of fields.

  7. #7
    driftking is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    4
    thank you,
    i am downloading it.

    if posible can you please prepare a tutorial about these so that i can learn how to make ms access form and commands.(i don't know anything about ms access module but have some experience about vb.net codes)

    i will be using ms access in my work place very often and has been doing major use on it before.

    kind regards

    if i encounter any issue with your program,will keep you inform.

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    My tutorials are just looking things up with google, I've just had enough experience to gather bits and pieces from several different sites and put it together. Before I wrote your example I'd never done anything of the sort before so preparing a tutorial would be like the blind leading the blind

    If you've had experience with VB that's all scripting in access is, vb code. So you shouldn't have any trouble translating what you know.

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

Similar Threads

  1. Replies: 0
    Last Post: 09-26-2012, 12:20 PM
  2. Replies: 1
    Last Post: 09-06-2012, 12:33 PM
  3. Exporting Data to Excel from a Web database
    By need_help12 in forum Import/Export Data
    Replies: 1
    Last Post: 05-16-2012, 04:59 PM
  4. Exporting a query to a specific Excel format
    By Ronald Mcdonald in forum Import/Export Data
    Replies: 3
    Last Post: 04-27-2012, 10:29 AM
  5. Exporting field to excel
    By Kipster1203 in forum Import/Export Data
    Replies: 5
    Last Post: 08-12-2010, 03:07 PM

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