By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

Update Query not updating

P: 68
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
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "UPDATE IndividualSettingsTbl SET " & _ 
  2. "IndividualSettingsTbl.LabelBKColor = '" & stLabelBoxBC & "'And IndividualSettingsTbl.LabelForeColor = '" & stLabelBoxFC & "' " & _ 
  3. "And IndividualSettingsTbl.LabelFontStyle = '" & stLabelFont & "' And IndividualSettingsTbl.TextComboBKColor = '" & stTextBoxBC & "' " & _ 
  4. "And IndividualSettingsTbl.TextComboForeColor = '" & stTextBoxFC & "' And IndividualSettingsTbl.TextComboFontStyle = '" & stTextFont & "' " & _ 
  5. "Where IndividualSettingsTbl.UserName = '" & AccountName & "';" 
  6.  
Thanks for helping
Apr 10 '08 #1
Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,489
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.

Expand|Select|Wrap|Line Numbers
  1. Debug.Print "UPDATE IndividualSettingsTbl SET " & _
  2.             "IndividualSettingsTbl.LabelBKColor = '" & stLabelBoxBC & "'And IndividualSettingsTbl.LabelForeColor = '" & stLabelBoxFC & "' " & _
  3.             "And IndividualSettingsTbl.LabelFontStyle = '" & stLabelFont & "' And IndividualSettingsTbl.TextComboBKColor = '" & stTextBoxBC & "' " & _
  4.             "And IndividualSettingsTbl.TextComboForeColor = '" & stTextBoxFC & "' And IndividualSettingsTbl.TextComboFontStyle = '" & stTextFont & "' " & _
  5.             "Where IndividualSettingsTbl.UserName = '" & AccountName & "';"
Apr 11 '08 #2

P: 68
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.

Expand|Select|Wrap|Line Numbers
  1. Debug.Print "UPDATE IndividualSettingsTbl SET " & _
  2.             "IndividualSettingsTbl.LabelBKColor = '" & stLabelBoxBC & "'And IndividualSettingsTbl.LabelForeColor = '" & stLabelBoxFC & "' " & _
  3.             "And IndividualSettingsTbl.LabelFontStyle = '" & stLabelFont & "' And IndividualSettingsTbl.TextComboBKColor = '" & stTextBoxBC & "' " & _
  4.             "And IndividualSettingsTbl.TextComboForeColor = '" & stTextBoxFC & "' And IndividualSettingsTbl.TextComboFontStyle = '" & stTextFont & "' " & _
  5.             "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
Apr 12 '08 #3

NeoPa
Expert Mod 15k+
P: 31,489
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.
Apr 14 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.