Results 1 to 12 of 12
  1. #1
    cslr is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    19

    help needed Queries to a new table with a macro


    i can creat a querie but how can i save it to a new table . would like to use a macro.

  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,822
    Why do you need to save query? This would be a MakeTable query.
    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
    cslr is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    19
    ok i am very new to this can that be done with a marco

  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,822
    Probably, I don't use macros, only VBA. The query would be built with the Access query designer, then macro code could run it.

    Again why is this necessary? Usually no need to save data produced by a query into another table.
    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
    cslr is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    19
    well what i am tring to do is have one table pull the information from it and save the information so i pull that information up lets say 2 day latter then change that data and save it but keep the old data in a file

  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,822
    What is it you are changing? Filter information? Still see no need to save another table. That is bad design practice. Can always revise the query with the older filter criteria to review that output again.
    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
    cslr is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    19
    it will be part of the records not the filter info . what i would like to do is save this quary to a file so it can be retreived againg and do anouther quairy make chages to the records and save that file .

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Save to a file? What kind - Excel spreadsheet? Or did you mean to say a table? Again, a MakeTable query is how to make a a new table from a query. Access Help has guidelines on building queries. Also, on how to build macros. Search on topic 'Introduction to Programming in Access'.
    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.

  9. #9
    cslr is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    19
    yes a new table sorry i export those table to a excel for some people to use . i now as you said make an table query but i need to automate this so anyone can just click on a button it will creat the table from the query and promt them so they can add a name to the new table . that table will be used in the futchure and pulled up by that name they gave it .

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I only use VBA, not macros. Either code method should be able to run a saved Access query. You will have to research how to setup a macro to run a query. Whichever code method used, need to set the button Click event property. For VBA code select [Event Procedure] in the Click event property. Double click the ellipses (...) and this will take you to the code editor. Type code in the procedure. VBA can run an SQL statement constructed in code. Example of this from my project:
    Code:
    Dim cn As ADODB.Connection
    Set cn = CurrentProject.Connection
        'Create the Table
        cn.Execute "CREATE TABLE " & Me.tbxTestNum & " (LabNum text(12) PRIMARY KEY Not Null, method text(30) Not Null);"
    The example creates a new empty table. I have never done code to create a new table from existing data. Never found the need to.

    Again, I recommend you review the Help guidelines.
    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.

  11. #11
    cslr is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    19
    thank you for all your help . i have decided i will need to do this a difrent way . instead of saving new table they will just need to enter all the data into one master table a querie from their . just need to find out how i can send a querie to excel know . againg it would neeed to be with a marcro or vba.
    thanks againg for taking the time to help me

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    A query can be exported to Excel. The code can either open the export wizard or can send the data directly to Excel. Review this thread http://forums.aspfree.com/microsoft-...el-414974.html
    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.

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

Similar Threads

  1. Macro to trigger emailing an updateable table
    By KOIBOY in forum Import/Export Data
    Replies: 5
    Last Post: 09-10-2011, 05:46 AM
  2. Help with table design needed.
    By bobojones69 in forum Database Design
    Replies: 0
    Last Post: 08-10-2010, 02:08 PM
  3. Help needed with table design/layout for newbie
    By jase118 in forum Database Design
    Replies: 8
    Last Post: 06-05-2010, 02:59 AM
  4. Replies: 0
    Last Post: 08-25-2008, 12:17 PM
  5. Replies: 0
    Last Post: 01-01-2007, 02:26 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