Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2009
    Posts
    85

    Unanswered: sql statement not working

    Can anyone tell me why this statement wont work


    Dim SQL_Text As String

    SQL_Text = "UPDATE Equipment SET Status = 'Available' WHERE DemoID = 'forms!frmDemoInventory!txtDemo' AND Status = 'Committed'"

    DoCmd****nSQL (SQL_Text), acEdit

    The problem is
    forms!frmDemoInventory!txtDemo

    (the me. operator dose not work either, though it will work out side of the sql statement later in my code to set focus)

    where txtDemo is a unbound text box on my form, and Status, DemoID are fields in my table Equipment

    If I use a specific value for txtDemo and place it in my code the sql statement work fine

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Presuming a numeric value:

    SQL_Text = "UPDATE Equipment SET Status = 'Available' WHERE DemoID = " & forms!frmDemoInventory!txtDemo & " AND Status = 'Committed'"

    If it's text, you'd need single quotes around the value.
    Paul

  3. #3
    Join Date
    Apr 2009
    Posts
    85
    Paul thank's for the reply. Clearly I do not yet understand how to put two statements together. In my 3 begging books on vba and sql, none had referenced the need to concatenate (I think that's a concatenation) of the two WHERE statements. They just put them together like I had. Thank again...Tim

  4. #4
    Join Date
    May 2005
    Posts
    1,191
    If you're looking for a good tutorial on building SQL in Access I would check out Martin Green's site. Cheers!
    Me.Geek = True

  5. #5
    Join Date
    Apr 2009
    Posts
    85
    Thank's Nick, I'm going to check it out right now. Tim

Posting Permissions

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