Results 1 to 8 of 8
  1. #1
    webisti is offline The Wisher
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    115

    Update query with comma as a separator

    Hi
    I have a update query where I want to update a table.Field it based on a criteria
    The price field in the table orders is called Price_USD and in this format : "#,###.00" (number ->double->standard)
    I want in the update query to insert a comment like "Check IT" on the field Comment when the Price_USD is over 9,999
    using the comma in the criteria is not possible because it gives an error Data type mismatch.



    Any ideas on how to do that?

    Thanks a lot
    Webisti

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I would use a label on a form and dynamically adjust the label's properties. The other option, if you truly desire to have it at the table level, would be to add a Boolean field or text field to your table and update that.

    EDIT:
    A third option would be to create an alias in your query and concatenate the text to the number field. You could use an Iif function in the alias too.

  3. #3
    webisti is offline The Wisher
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    115
    or would you use vba?

  4. #4
    webisti is offline The Wisher
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    115
    He is the code in sql
    Code:
    UPDATE Orders SET Orders.Comment = "Check- Value over 10K USD"
    WHERE (((Order.PRICE_USD)>"9,999.00"));
    How to make it work to update the comment..

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I think I see the problem.

    Instead of
    WHERE (((Order.PRICE_USD)>"9,999.00"));

    try
    WHERE (((Order.PRICE_USD)> 9999));

  6. #6
    webisti is offline The Wisher
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    115
    I had it like that before but was not working....cannot figure out why.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Specificaly to the problem you are adressing regarding the UPDATE query. It is not making sense why, as you stated already. Have you tried using the query builder and adding

    Code:
     >9999
    to the criteria field? What does the SQL look like using the query builder?





    The other issue is that you are updating a field in a table based on a calculation. So I will comment on that point. It is not associated with the problem you are posting about but, it is generaly not a good idea to store calculated data. So something like the third option I offered earlier should be considered.

    You could create a select query based on the table Orders. Create an alias that has an IIf. So you would create a new column by entering the following in a blank field.

    Code:
    MyNewAlias: IIf([Order].[PRICE_USD] > 9999.99, "Check- Value over 10K USD", "Acceptable")
    You need to verify the data type of Price_USD

  8. #8
    webisti is offline The Wisher
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    115
    Thanks ITsMe

    I did used your third option by creating another query where it gives the result I want and in the original query updating the comment with "MyNewAlias".
    It worked smoothly, thanks again.

    Webisti

Please reply to this thread with any new information or opinions.

Similar Threads

  1. exporting query to text comma separated
    By Pasi in forum Queries
    Replies: 6
    Last Post: 12-27-2013, 06:42 PM
  2. comma in a query
    By jscriptor09 in forum Access
    Replies: 1
    Last Post: 05-18-2012, 04:18 PM
  3. Replies: 1
    Last Post: 11-30-2011, 01:13 AM
  4. Replies: 15
    Last Post: 10-14-2010, 12:22 PM
  5. Syntax error (comma) in query expression?
    By TheWolfster in forum Queries
    Replies: 5
    Last Post: 05-10-2010, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums