Results 1 to 5 of 5
  1. #1
    laosu is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    3

    VBA- duplicate table to Access from SQL Server

    Hi,

    I would like to duplicate table from SQL Server 2000 to Access using VBA.


    Could anyone please show me how to programmatically establish a connection to SQL Server using VBA codes?

    Thanks in advance.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Just curious-- Why?
    Why not link or import?

  3. #3
    laosu is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    3
    Quote Originally Posted by orange View Post
    Just curious-- Why?
    Why not link or import?
    I want to use sql query to link only certain data into Access.
    I found Linked Table doesn't provide this capability for us to specify the condition on selecting data using sql query.Instead, it will import whole table. Hence, i want to try to link using query programmatically.

    Do you have any idea on this? to link table using query via Linked table?

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Have you tried linking the table, then creating a query to select only the fields you are interested in?

    For example the table (hostTable) contains fields f1,f2,f3,f4,f5...f99 and you are interested in f2,f36 and f50.
    Link to table hostTable
    create MyQuery where you Select f2,f36,f50 from hostTable

    You can then use MyQuery as you wish.

  5. #5
    laosu is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    3

    Red face

    Quote Originally Posted by orange View Post
    Have you tried linking the table, then creating a query to select only the fields you are interested in?

    For example the table (hostTable) contains fields f1,f2,f3,f4,f5...f99 and you are interested in f2,f36 and f50.
    Link to table hostTable
    create MyQuery where you Select f2,f36,f50 from hostTable

    You can then use MyQuery as you wish.

    I get what you mean. Could you provide me the vba codes to do so?

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

Similar Threads

  1. Replies: 1
    Last Post: 01-22-2011, 12:23 PM
  2. link sql server table to access
    By broken_ice in forum Access
    Replies: 0
    Last Post: 06-28-2010, 12:50 PM
  3. Linked SQL Server Table Problems
    By jalton in forum Import/Export Data
    Replies: 3
    Last Post: 02-13-2010, 12:52 AM
  4. Linked Table To SQL Server?
    By snkscore in forum Import/Export Data
    Replies: 3
    Last Post: 12-09-2009, 06:36 AM
  5. Duplicate add to new table
    By horseyshoe in forum Access
    Replies: 3
    Last Post: 09-01-2006, 07:51 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