Results 1 to 9 of 9
  1. #1
    Dave_D's Avatar
    Dave_D is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    67

    ALTER sequence counter on LINKED Tables

    I recently switched 2 data table to BE. Prior to doing this, I was issuing the following



    CurrentDb.Execute "ALTER TABLE tablename ALTER COLUMN Sequence Counter (1,1)"

    Which worked perfectly fine, but after making the switch to BE my code became

    SET appAccess = OpenCurrentDb("C:\ ...." , FALSE)
    Msgbox Err.Number - returns 0
    appAccess.RUN "Altercol" tablename

    In the BE DB, I placed the CurrentDb.Execute "ALTER....." statement in a MODULE, but I get a runtime error 438 on appAccess.RUN.

    1. Does appAccess become my current DB?
    2 Is this acceptable to alter a linked table?
    3 What would be the proper syntax to perform the ALTER? Is it merely writing an SQL statement and them executing that stateement?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    you cannot alter linked tables in the FE.
    you must be IN the BE to alter them. But why alter them in code? when you can just edit the new field.

  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,521
    I know you can do it from outside the BE because I've sent utility db's to clients to update back end tables. I'll try to dig up the code. I can't remember if I used DAO or SQL.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Dave_D's Avatar
    Dave_D is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    67
    Quote Originally Posted by ranman256 View Post
    you cannot alter linked tables in the FE.
    you must be IN the BE to alter them. But why alter them in code? when you can just edit the new field.
    When I issue the OpenDataBase(C:\....) I am opening the BE to allow the sequencing to renumber. So if the BE is opened, shouldn't I be able to ALTER those tables by using either SQL or DAO?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Found it. I used SQL. Your issue is you're not using the db variable to execute the SQL. Try

    appAccess.Execute "ALTER TABLE...", dbFailOnError
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Dave_D's Avatar
    Dave_D is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    67
    Quote Originally Posted by pbaldy View Post
    Found it. I used SQL. Your issue is you're not using the db variable to execute the SQL. Try

    appAccess.Execute "ALTER TABLE...", dbFailOnError
    Paul,
    That worked beautifully! Thank you. So maybe you can resolve my second issue now, where I get a runtime error 3295 - Syntax error in DROP TABLE or DROP INDEX.

    Set db = Currentdb
    For Each tbldef in db.Tabledef
    If tbldef.name = "tablename" Then
    db.execute "DROP TABLE" & tbldef.name, dbFailOnError ----> Runtime error 3295
    End if
    Next tbldef

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    For starters, without a space after TABLE that will concatenate to:

    db.execute "DROP TABLEtablename

    which the engine probably won't be able to resolve.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    Dave_D's Avatar
    Dave_D is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    67
    Quote Originally Posted by pbaldy View Post
    For starters, without a space after TABLE that will concatenate to:

    db.execute "DROP TABLEtablename

    which the engine probably won't be able to resolve.
    I got it resolved. There was a space, just can't type correctly, but I needed to put brackets around my table name because of the way it was named.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you got it sorted. Brackets would have been next on my list.
    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. Replies: 1
    Last Post: 10-17-2019, 09:14 AM
  2. Replies: 27
    Last Post: 12-02-2015, 06:09 PM
  3. Counter in a query with joined tables
    By plus_stick in forum Queries
    Replies: 1
    Last Post: 10-30-2014, 06:36 AM
  4. Query with Counter from multiple tables
    By dmenger in forum Queries
    Replies: 3
    Last Post: 03-25-2014, 11:07 PM
  5. alter table to add a column in a linked table
    By markjkubicki in forum Programming
    Replies: 6
    Last Post: 02-09-2012, 08:13 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