Results 1 to 5 of 5

Thread: syntax error

  1. #1
    Join Date
    May 2002
    Posts
    395

    Unanswered: syntax error

    I received a syntax error I'm quite sure is on b(j). But I how else can I write this?

    For j = 0 To 12 Step 1
    StrSQL = "INSERT INTO tblRGAAnalysis (Quarter) Values (" & b(j) & ");"
    db.Execute StrSQL

    Next j

    Thanks!!

    :

  2. #2
    Join Date
    May 2002
    Posts
    395

    To: Playernovis can't open link

    Originally posted by alicejwz
    I received a syntax error I'm quite sure is on b(j). But I how else can I write this?

    For j = 0 To 12 Step 1
    StrSQL = "INSERT INTO tblRGAAnalysis (Quarter) Values (" & b(j) & ");"
    db.Execute StrSQL

    Next j

    Thanks!!

    :
    Can't open link you sent. Please resend response.

    Thank you!!

  3. #3
    Join Date
    Nov 2002
    Location
    San Francisco
    Posts
    251

    Re: To: Playernovis can't open link

    generally say, your statement is OK....

    I can see the only problem in your function B

    make sure you pass IN and OUT of this function correct numeric or character values..... If you pass OUT of your function B character don't forget to add doublequotes in your SQL statement. Also I really recomment to use use explicit declaration (simply say DIM all the variables).

    I have Access97 (I know, but this company is cheap) and it works just fine....


    jiri

    'this works just fine
    Sub test()
    Dim j As Byte
    Dim strSQL As String

    For j = 0 To 12 Step 1
    strSQL = "INSERT INTO tblRGAAnalysis (Quarter) Values (" & B(j) & ");"
    CurrentDb.Execute strSQL
    Next j

    End Sub


    Function B(inputV As Byte) As Long
    B = inputV + 3
    End Function

  4. #4
    Join Date
    Nov 2002
    Location
    San Francisco
    Posts
    251
    this is the same function with CHARACTER OUT from function B

    Sub test()
    Dim j As Byte
    Dim strSQL As String

    For j = 0 To 12 Step 1
    strSQL = "INSERT INTO tblRGAAnalysis (Quarter) Values (" & chr(34) & B(j) & chr(34) & ");"
    CurrentDb.Execute strSQL
    Next j

    End Sub


    Function B(inputV As Byte) As string
    B = CStr(inputV) & " Hi"
    End Function

  5. #5
    Join Date
    May 2002
    Posts
    395

    syntax error UPDATE in SQL statement

    Originally posted by playernovis
    this is the same function with CHARACTER OUT from function B

    Sub test()
    Dim j As Byte
    Dim strSQL As String

    For j = 0 To 12 Step 1
    strSQL = "INSERT INTO tblRGAAnalysis (Quarter) Values (" & chr(34) & B(j) & chr(34) & ");"
    CurrentDb.Execute strSQL
    Next j

    End Sub


    Function B(inputV As Byte) As string
    B = CStr(inputV) & " Hi"
    End Function

    Thanks for your help!

    Do you know how to use UPDATE in the SQL statement instead of INSERT INTO ?
    I have two dimension array that I would like to populate 20 values into each row for 13 columns. The INSERT INTO incremented to a new row and placed next value. I received a syntax error in UPDATE.
    Do you know why?

    Thanks!!

Posting Permissions

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