Results 1 to 7 of 7
  1. #1
    Join Date
    May 2013
    Posts
    28

    Question Unanswered: Automatic Exporting

    Hello all,

    I have another problem I need help with. So What I am wanting to do is export a table to Excel automatically. I want to do a number of steps with the click of a button.

    I currently have three Tables
    1. Products
    2. Languages
    3. Translations Full

    So I want to select a Product with a drop down box and click a button. I want this button to make a multiple tables. These tables will be a table of the given product selected and each language as their own table. The table will contain values ENG, ID, CurrentTranslation. These values will be taken from the Translations Full table.

    So basically I will be filtering Translations Full by a given product and then I will want a function that will loop through each language and create appropriate tables(Use Languages table to create criteria for loop?). I would like the tables to be names Product_Language(depending on product and language used to make table)

    Next Once all the tables are created for the selected Product I will want it to automatically export each of those tables to Excel and have them saved in a certain file destination. After all tables are exported I then want the Table to be deleted so clutter of tables does not build up.

    It might be better to Export and Delete once the Table is first created instead of creating all tables and then doing those steps.

    Could anyone help with coding this as this is way above my head?

    If unclear please ask. I am also able to link my database if it would be useful to have.

    Thanks For Any Help!

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    assuming your tables are properly designed you shouldn't have to do looping. the whole point of using a relational db is to leverage the power of SQL
    marshall your data using a query and export that query to whatever file type you need to.
    don't create tables, there is no need to create a table a query should be abel to extract the dataas required.
    so its down to your data, your query.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    May 2013
    Posts
    28
    I wouldn't even know where to start on what you just said. How would I make a query to export data to multiple files for multiple types of filters with one single click. I am a massive amateur.

  4. #4
    Join Date
    May 2013
    Posts
    28
    Code:
    Private Sub Create_Specific_Table_Click()
    Dim GetTblName As String
    GetTblName = Me.cboProductChoice & "_" & Me.cboLanguageChoice
    DoCmd****nSQL "SELECT [Translations Full].ENG, [Translations Full].ID, [Translations Full].CurrentTranslation INTO " & GetTblName & " FROM [Translations Full] WHERE ((([Translations Full].Product)=[Forms]![Make Export Table]![cboProductChoice]) AND (([Translations Full].Language)=[Forms]![Make Export Table]![cboLanguageChoice]));"
    End Sub
    I already have this code. It takes the infor from Products and Languages drop down box to create the table. I was thinking I could just make a loop to go through Languages and then make the table, export, then delete.

  5. #5
    Join Date
    Jan 2005
    Posts
    146
    Hi kpelkey151. Maybe I could get a job from you. Here is an updated version of the DB I still had from previous. I am using the same form for selecting the Product and added a new button. This code will ask for file location and name and then will output all the languages for a product into this excel file. It does not create any tables and is automatic.

    OK, good luck.
    Attached Files Attached Files

  6. #6
    Join Date
    May 2013
    Posts
    28
    Thanks Alot Mate! I think it would have taken years to come up with that code. Did you just type that real quick or did you already have that from a previous project?

  7. #7
    Join Date
    Jan 2005
    Posts
    146
    Neither. I read your post yesterday and went about my day thinking about it here and there. Initially I didn't know what to do. Once I had an idea it took about 30 minutes to write but really took a while to decide what to do. Sometimes I have moments of clarity, other times don't ask. This time it worked.

    Hopefully your really working on something really useful, it would make me feel better to know.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •