Results 1 to 4 of 4
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,095

    CREATE TABLE syntax error

    From Debug.Print:
    Code:
    CREATE TABLE 'tblLog' (LogEvent Text)
    I don't see the problem?

    The code:


    Code:
    Public Function InitLog(tblName As String) As Integer
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '  Create the new table and bind it to the DAO Recordset rsLog.  The logging action
    '  will record the actions into the DAO Recordset.
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    
    
    On Error Resume Next
    DoCmd.DeleteObject acTable, tblName        'Get rid of any old log table
    On Error GoTo ErrorHandler
    
    
    Debug.Print "CREATE TABLE '" & tblName & "' (LogEvent Text)"
    CurrentDb.Execute "CREATE TABLE '" & tblName & "' (LogEvent Text)"    'Create a new log table
    Set rsLog = DBEngine(0)(0).OpenRecordset(tblName)         'Bind new log to DAO REcordset
    
    
    InitLog = 0
    
    
    NormalExit: Exit Function
    
    
    ErrorHandler:   InitLog = Err.Number
                    MsgBox "Initialization error " & Err.Number & "  " & Err.Description
                    GoTo NormalExit
    End Function

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,553
    Perhaps get rid of the single quotes?

    Code:
    ? initlog("testLog")
    CREATE TABLE testLog (LogEvent Text)
     0
    ALso rsLog does not exist, so that tells me no Option Explicit?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,095
    ALso rsLog does not exist, so that tells me no Option Explicit?
    At the top of the general module in which contains the function

    Code:
    Option Compare Database
    Option Explicit
    Dim rsLog As DAO.Recordset
    
    SNIP
    
    Public Function InitLog(tblName As String) As Integer
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '  Create the new table and bind it to the DAO Recordset rsLog.  The logging action
    
    SNIP
    And yes, Access didn't like the single quotes.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,553
    So please supply ALL code for anyone else to test.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 15
    Last Post: 03-01-2021, 12:07 PM
  2. Replies: 5
    Last Post: 09-16-2018, 01:18 PM
  3. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  4. Replies: 1
    Last Post: 08-06-2012, 07:15 AM
  5. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 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