Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    nd0911 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    31
    Hi davegri,

    First thanks for the great tip's but:

    1. I tried to convert my ACCDB file to ACCDR (I changed the suffix) and it works just fine, but in the real Runtime it false.



    2. I tried the code you attached but I'm not sure I understand it, why the following line of code is not ״Chained text״ ?


    Code:
    arg = format(IdField,"000000000")


    3. I did same update to your code and it works just fine, but again, it works only on the regular Access and not in the run time version

    Code:
    Public Sub SetId_9(tblName As String, IdField As String)
    Dim SQL As String
    
    
    SQL = "UPDATE " & tblName & " SET " & IdField & " = " & "Format([" & IdField & "]," & """" & "000000000" & """)"
    
    
    CurrentDb.Execute SQL
    End Sub








  2. #17
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Well, we tried 2 different approaches. If it still doesn't work in the runtime, I'm at a loss. I don't have runtime installed and am not inclined to do so.

  3. #18
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you are too focussed on your double quotes and what the sql string looks like

    SQL = "UPDATE [" & tblName & "] SET [" & IdField & "] = '" & Format(IdField,"000000000") & "'"
    Last edited by CJ_London; 06-12-2017 at 03:45 AM.

  4. #19
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Code:
      SQL = "UPDATE " & tblName & " SET IdField = " & arg
    
        Debug.Print SQL
    
        Currentdb.Execute SQL
    I read this morning that Runtime wont let you alter the format of tables.

    Isn't what you're doing an example of this?

    Perhaps it would work if you did this as part of a query?

  5. #20
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    I read this morning that Runtime wont let you alter the format of tables.
    not true. Runtime does not have the ability to edit tables using the usual gui but you can still do it in vba code to execute SQL create table, alter table etc. When you click the 'update table' button, Access creates and runs the required sql in the same way.

  6. #21
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Reading through this thread again, I notice that the OP never specified the error thrown, so let's find out with an error handler. Maybe it's not this procedure at all.
    Actually, if using the runtime is anticipated, EVERY procedure should have an error handler. Without one, the runtime will terminate Access for any error, and leave the user bewildered.

    Code:
    Public Sub SetId_9(tblName As String, IdField As String)
        On Error GoTo SetId_9_Error
        Dim SQL As String
        Dim arg As String
        arg = Format(IdField, "000000000")
        Debug.Print arg
        SQL = "UPDATE " & tblName & " SET IdField = " & arg
        Debug.Print SQL
    SetId_9_EXIT:
        Exit Sub
    SetId_9_Error:
        Select Case Err
            Case Else
                MsgBox Err.Number & ", " & Err.Description
        End Select
        Resume SetId_9_EXIT
    End Sub

  7. #22
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    I notice that the OP never specified the error thrown
    I've mentioned it a number of times but to no avail

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 01-18-2017, 09:11 AM
  2. ms access runtime version for other computers
    By charlesgardner51 in forum Access
    Replies: 1
    Last Post: 09-09-2015, 03:27 PM
  3. Runtime version Access 2003 error 429
    By Docjsj in forum Programming
    Replies: 1
    Last Post: 06-25-2015, 08:14 AM
  4. 2010 Runtime version
    By crowegreg in forum Access
    Replies: 4
    Last Post: 08-10-2012, 11:48 AM
  5. Replies: 1
    Last Post: 02-10-2012, 05:53 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