Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Location
    Phoenix, AZ
    Posts
    122

    Unanswered: run update query in code

    i have some code that runs an update query. I need to reference an ID number on a form for this update query and i keep getting an error that says something like... "YOU CANT REFERENCE A PROPERTY OR METHOD FOR CONTROL UNLESS THE PROPERTY OR METHOD HAS THE FOCUS." Here is a copy of my code. Can this be done?

    SQL = "UPDATE Issues SET Issues.QStatus = 'CONFIRMED' " & _
    "WHERE (((Issues.ID)=" & Forms!Issues!ID.Text & "));"

    DoCmd.SetWarnings False
    DoCmd.RunSQL SQL
    DoCmd.SetWarnings True


    the part i highlighted in blue is giving me the trouble.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    delete .Text
    the .Text property has it's uses, but yours is not one of them.
    use the .Value property (which is also the default property so you don't need to explicitly write .Value)

    don't use warnings/runsql/warnings if you are talking to a JET database. use
    currentdb.execute SQL
    it is faster, simpler, safer.

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Dec 2002
    Location
    Phoenix, AZ
    Posts
    122
    Thanks IZY

    as always- it work great!


    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
  •