Results 1 to 8 of 8
  1. #1
    scorpion99 is offline Novice
    Windows 7 32bit Access 2002
    Join Date
    Nov 2013
    Posts
    27

    cannot insert into SQL linked table from an access form

    Hi all,

    I have a form where I am using the following in my VBA code where I defined an STRSQL as Insert into....
    and CurrentDb.Execute STRSQL

    It is working fine for local table but when I tried to use it on a linked table, nothing is inserted and I don't get any error message.

    Note that if I convert the linked table to local, inserting works fine also.



    I have a primary key in my linked table and I am able to fill it manually.

    I also noticed that most of my data type in the linked table are as Text and not as Date as defined on SQL server.

    The SQL user that I used have writing permissions to the table.

    What could be the problem? Can someone help?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Don't use current db.execute....use docmd.runsql

    or your external table is not uupdatable.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Execute should still work in my experience. Make sure the linked table has a primary key, or it will be read only.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,842
    I also noticed that most of my data type in the linked table are as Text and not as Date as defined on SQL server.
    just to check - are you linked to the actual table? or a view? if you are seeing field types as text when they are actual dates implies a view which has formatted the dates.

    I have a primary key in my linked table and I am able to fill it manually.
    Do you mean if you open the linked table directly, you can add new records?

  5. #5
    scorpion99 is offline Novice
    Windows 7 32bit Access 2002
    Join Date
    Nov 2013
    Posts
    27
    @ranman256 ,
    I applied your command but I am getting the following and nothing is updated.
    Click image for larger version. 

Name:	error.jpg 
Views:	5 
Size:	49.4 KB 
ID:	20248

    @Ajax,
    Yes , I can fill it manually on access and see the changes on SQL (It is also a table there). Here are the data fields types on both SQL and access when linked.(Sorry but I had to hide the field names for company confidentiality.
    Click image for larger version. 

Name:	fields.jpg 
Views:	5 
Size:	80.3 KB 
ID:	20249

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    What does the finished SQL look like? Try the method here to test it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    scorpion99 is offline Novice
    Windows 7 32bit Access 2002
    Join Date
    Nov 2013
    Posts
    27
    SQL standard edition 2012 , what method?

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Sorry, forgot to paste the link:

    http://www.baldyweb.com/ImmediateWindow.htm

    i meant the SQL of the append query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Insert INTO MS SQL Linked table too slow
    By green78 in forum SQL Server
    Replies: 5
    Last Post: 05-28-2015, 09:33 AM
  2. Replies: 4
    Last Post: 03-02-2015, 07:54 PM
  3. Input form for an excel linked access table?
    By marcvanderpeet12 in forum Access
    Replies: 1
    Last Post: 02-28-2014, 10:35 AM
  4. Slow INSERT on a Linked SQL Table
    By altemir in forum SQL Server
    Replies: 5
    Last Post: 07-22-2013, 04:57 PM
  5. Replies: 2
    Last Post: 12-22-2010, 01:46 PM

Tags for this Thread

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