Update Query not updating

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Trevor2007
    New Member
    • Feb 2008
    • 68

    Update Query not updating

    my update query, when run says its going to update X # of rows but when I check the table after the update the values haven't changed, I have checked my varables that I passing to the query with msgbox [string var} to varvify that an actual # is being passed and that is correct. here is my query
    Code:
    DoCmd.RunSQL "UPDATE IndividualSettingsTbl SET " & _ 
    "IndividualSettingsTbl.LabelBKColor = '" & stLabelBoxBC & "'And IndividualSettingsTbl.LabelForeColor = '" & stLabelBoxFC & "' " & _ 
    "And IndividualSettingsTbl.LabelFontStyle = '" & stLabelFont & "' And IndividualSettingsTbl.TextComboBKColor = '" & stTextBoxBC & "' " & _ 
    "And IndividualSettingsTbl.TextComboForeColor = '" & stTextBoxFC & "' And IndividualSettingsTbl.TextComboFontStyle = '" & stTextFont & "' " & _ 
    "Where IndividualSettingsTbl.UserName = '" & AccountName & "';"
    Thanks for helping
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    Your first step should always be to print off the string you're intending to pass to the SQL engine and see if that still makes sense.

    If you can't see anything wrong with it, post the string in here.

    Code:
    Debug.Print "UPDATE IndividualSettingsTbl SET " & _
                "IndividualSettingsTbl.LabelBKColor = '" & stLabelBoxBC & "'And IndividualSettingsTbl.LabelForeColor = '" & stLabelBoxFC & "' " & _
                "And IndividualSettingsTbl.LabelFontStyle = '" & stLabelFont & "' And IndividualSettingsTbl.TextComboBKColor = '" & stTextBoxBC & "' " & _
                "And IndividualSettingsTbl.TextComboForeColor = '" & stTextBoxFC & "' And IndividualSettingsTbl.TextComboFontStyle = '" & stTextFont & "' " & _
                "Where IndividualSettingsTbl.UserName = '" & AccountName & "';"

    Comment

    • Trevor2007
      New Member
      • Feb 2008
      • 68

      #3
      Originally posted by NeoPa
      Your first step should always be to print off the string you're intending to pass to the SQL engine and see if that still makes sense.

      If you can't see anything wrong with it, post the string in here.

      Code:
      Debug.Print "UPDATE IndividualSettingsTbl SET " & _
                  "IndividualSettingsTbl.LabelBKColor = '" & stLabelBoxBC & "'And IndividualSettingsTbl.LabelForeColor = '" & stLabelBoxFC & "' " & _
                  "And IndividualSettingsTbl.LabelFontStyle = '" & stLabelFont & "' And IndividualSettingsTbl.TextComboBKColor = '" & stTextBoxBC & "' " & _
                  "And IndividualSettingsTbl.TextComboForeColor = '" & stTextBoxFC & "' And IndividualSettingsTbl.TextComboFontStyle = '" & stTextFont & "' " & _
                  "Where IndividualSettingsTbl.UserName = '" & AccountName & "';"
      nothing came back with debug.print and It looked like every now and then fields in the table would update with boleon so I replaced And with ,
      and it works

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        Clearly you're past your current problem, but this is such a useful feature I can't leave you in ignorance.

        If "nothing came back" then you are clearly not looking in the correct place.

        You have two options :
        1. Use the MsgBox() function to display the information instead.
          This has the benefit that it is obvious and impossible to miss.
          It has the drawback that it is hard to copy the details into a post to review.
        2. Continue to use Debug.Print (which does NOT stop or pause the flow of the code) and find the results by, from the VBA code editing window type Ctrl-G to open the Immediate Pane. The output of Debug.Print is found in there.

        Comment

        Working...