We help IT Professionals succeed at work.

Combo Box syntax for Update Query

ca1358
ca1358 asked
on
Medium Priority
780 Views
Last Modified: 2008-01-09
What is the correct syntax for a combo box value in an update query?

Private Sub Combo91_Click()
Dim sql As String
               
 sql = "update [Roll Exception Report] set [Denied/Approved Mandatory] =  [combo91.value] where [company number] = " & Me.[Text38]
 CurrentDb.Execute sql, dbFailOnError
 Me.Refresh

End Sub


I get an error [Combo91.value]

Any help would be appreciated!!
Comment
Watch Question

Top Expert 2005

Commented:
if [Denied/Approved Mandatory] is numeric

sql = "update [Roll Exception Report] set [Denied/Approved Mandatory] ="  &me.[combo91].value & " where [company number] = " & Me.[Text38]

if [Denied/Approved Mandatory] is string

sql = "update [Roll Exception Report] set [Denied/Approved Mandatory] ="""  &me.[combo91].value & """ where [company number] = " & Me.[Text38]
Top Expert 2005
Commented:
does it MS Access?

will be
if [Denied/Approved Mandatory] is numeric

sql = "update [Roll Exception Report] set [Denied/Approved Mandatory] ="  &me.[combo91] & " where [company number] = " & Me.[Text38]

if [Denied/Approved Mandatory] is string

sql = "update [Roll Exception Report] set [Denied/Approved Mandatory] ="""  &me.[combo91]  & """ where [company number] = " & Me.[Text38]

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
sql = "update [Roll Exception Report] set [Denied/Approved Mandatory] ="""  &me.[combo91]  & """ where [company number] = " & Me.[Text38]


this worked but before I close this out, could you please tell how to stop the "write conflict" when it hits
me.requery

Thank you very much!!
Top Expert 2005

Commented:
You probably updating same table as record source of your form,may be better to
bound combo91 to Denied/Approved Mandatory field
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.