Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2010

    Unanswered: run time error in access vba 2007

    hi all,

    i am new to vba programming in access 2007 i am trying to create a recordset using the following code :

    Sub pract()
    Dim cnn1 As ADODB.Connection
    Set cnn1 = CurrentProject.Connection
    Dim myRecordSet As New ADODB.Recordset
    myRecordSet.ActiveConnection = cnn1
    'We’ll put lengthy SQL statement in variable named mySQL.
    Dim mysql As String
    mysql = "SELECT, Table1.count,"
    mysql = mysql & "FROM Table1"
    'Now we use mySQL variable name in statement below.
    myRecordSet.Open mysql
    End Sub

    but facing an error saying that : the select statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.

    please try to to help me out.

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 15
    Count is a reserved word in SQL.
    Have a nice day!

  3. #3
    Join Date
    Dec 2004
    Madison, WI
    Sinndho makes a GREAT point! Field/Table naming is crucial! NEVER, EVER use reserved words for field/table names (along with spaces in field/table names.) If you're unsure, google reserved words in MSAccess and avoid these as field/table names. It will make your life miserable using reserved words and trying to troubleshoot code!
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts