Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    110

    Unanswered: Simple update query

    Hello everybody

    I`m trying to write a simple update query. The code looks something like this :

    strUpdate = "UPDATE EPISKEYH SET Kwdikos_texnikou = Me.[Kwdikos_texnikou] WHERE Kwdikos_episkeyhs = 203;"

    MsgBox (strUpdate)
    CurrentDb.Execute (strUpdate)

    When I execute it, I get an error 'Too few parameters. Expected at least one.' Any ideas?

    George Papadopoulos

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    Try doing that through DoCmd.RunSQL("Update ....")

  3. #3
    Join Date
    Jul 2003
    Posts
    73
    You'll need to do it like this:

    Code:
    strUpdate = "UPDATE EPISKEYH SET Kwdikos_texnikou = " & Me.[Kwdikos_texnikou] & " WHERE Kwdikos_episkeyhs = 203;"
    
    currentDb.OpenRecordset(strUpdate)
    When you want to use a value from your form in the UPDATE statement - you need to place it outside the quotes as shown above. I don't know about the CurrentDb.Execute method (it may be fine) - but the one I've used above also works.
    Joel Dixon
    Analyst Programmer
    Melbourne, Australia

  4. #4
    Join Date
    Apr 2004
    Posts
    110
    ok. now I`ve used the syntax

    strUpdate = "UPDATE EPISKEYH SET EPISKEYH.Kwdikos_texnikou = '" & Me.[Kwdikos texnikou] & "'"
    strUpdate = strUpdate & ", EPISKEYH.Kwdikos_mhxanhmatos = '" & Me.[Kwdikos mhxanhmatos] & "'"
    strUpdate = strUpdate & ", EPISKEYH.Kwdikos_klinikhs = '" & Me.[Kwdikos klinikhs] & "'"
    strUpdate = strUpdate & ", EPISKEYH.Hmeromhnia = #" & Me.[Hmeromhnia] & "#"
    strUpdate = strUpdate & ", EPISKEYH.Wra_enarjhs = " & Me.[Wra enarjhs]
    strUpdate = strUpdate & ", EPISKEYH.Wra_lhjhs = " & Me.Wra_lhjhs
    strUpdate = strUpdate & ", EPISKEYH.Aitia_blabhs = " & Me.Aitia_blabhs
    strUpdate = strUpdate & ", EPISKEYH.Katastash = " & Me.Katastash
    strUpdate = strUpdate & ", EPISKEYH.Ek8esh_texnikou = '" & Me.Ek8esh_texnikou & "'"
    strUpdate = strUpdate & " WHERE EPISKEYH.Kwdikos_episkeyhs = '" & Me.Kwdikos_episkeyhs & "';"

    I still get an error with Wra_enarjhs, Wra_lhjhs which contain time. Do I need to use a specific prefix for time fields?

    thx, for the advice George

  5. #5
    Join Date
    Jul 2003
    Posts
    73
    I don't know this one. Dates and Times are both stored in a Date/Time field - so a guess would be to add the # characters to the Time fields as you have done with the date fields.

    Again - this is just a guess.
    Joel Dixon
    Analyst Programmer
    Melbourne, Australia

Posting Permissions

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