Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2009
    Posts
    9

    Unanswered: error in insert statement

    what's wrong with my code when an error: 'Too few parameters. Expected 1' pops-up? it is an insert statement by the way. this is my code:

    Dim lngResult As Long
    IngResult = DMax("GIID", "tblGenInfo")

    strSql = ("INSERT INTO tblResult(GIID, " & _
    " DI, D2, D3, D4, D5," & _
    " E1, E2, E3, E4, E5," & _
    " F1, F2, F3, F4, F5," & _
    " G1, G2, G3, G4, G5," & _
    " H1, H2, H3, H4, H5," & _
    " I1, I2, I3, I4, I5) " & _
    "VALUES (lngResult, " & _
    " '" & Me.cboD1 & "', '" & Me.cboD2 & "', '" & Me.cboD3 & "', '" & Me.cboD4 & "', '" & Me.cboD5 & "', " & _
    " '" & Me.cboE1 & "', '" & Me.cboE2 & "', '" & Me.cboE3 & "', '" & Me.cboE4 & "', '" & Me.cboE5 & "', " & _
    " '" & Me.cboF1 & "', '" & Me.cboF2 & "', '" & Me.cboF3 & "', '" & Me.cboF4 & "', '" & Me.cboF5 & "', " & _
    " '" & Me.cboG1 & "', '" & Me.cboG2 & "', '" & Me.cboG3 & "', '" & Me.cboG4 & "', '" & Me.cboG5 & "', " & _
    " '" & Me.cboH1 & "', '" & Me.cboH2 & "', '" & Me.cboH3 & "', '" & Me.cboH4 & "', '" & Me.cboH5 & "', " & _
    " '" & Me.cboI1 & "', '" & Me.cboI2 & "', '" & Me.cboI3 & "', '" & Me.cboI4 & "', '" & Me.cboI5 & "') ")
    Set db = CurrentDb()
    db.Execute strSql, dbFailOnError

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    You have to concatenate the variable just as you have to concatenate form references (no single quotes though).
    Paul

Posting Permissions

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