Results 1 to 3 of 3
  1. #1
    Lorlai is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    107

    Exclamation Update Query Works Once

    I'm about to go insane here. I have an update query that works just fine when I run it given one set of data, then gives me a type conversion error when I try it with similar data that has a different filter.



    This works:
    Code:
    UPDATE Products 
    SET Products.[Worker Headcount Qrt1] = 
    DLookUp("AvgQtr1","[Qtr_HeadCount_Worker]","[Product No]=" & Products.[ID]), Products.[Worker Headcount Qrt2] = 
    DLookUp("AvgQtr2","[Qtr_HeadCount_Worker]","[Product No]=" & [Products].[ID]), Products.[Worker Headcount Qrt3] = 
    DLookUp("AvgQtr3","[Qtr_HeadCount_Worker]","[Product No]=" & [Products].[ID]), Products.[Worker Headcount Qrt4] = 
    DLookUp("AvgQtr4","[Qtr_HeadCount_Worker]","[Product No]=" & [Products].[ID]);
    This does not:
    Code:
    UPDATE Products 
    SET Products.[Manager Headcount Qrt1] =
     DLookUp("AvgQtr1","[Qtr_HeadCount_Manager]","[Product No]=" &  Products.[ID]), Products.[Manager Headcount Qrt2] = 
     DLookUp("AvgQtr2","[Qtr_HeadCount_Manager]","[Product No]=" &  [Products].[ID]), Products.[Manager Headcount Qrt3] =  
    DLookUp("AvgQtr3","[Qtr_HeadCount_Manager]","[Product No]=" &  [Products].[ID]), Products.[Manager Headcount Qrt4] =  
    DLookUp("AvgQtr4","[Qtr_HeadCount_Manager]","[Product No]=" &  [Products].[ID]);
    I have checked that both tables have the same data types, and they do. The only difference between the two is Qtr_HeadCount_Worker counts the number of records associated with "Worker" and Qtr_HeadCount_Manager counts the records associated with "Manager".

    Is there something I am missing?

    Please help!

    Thank you

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    are you implying that going insane is bad thing?

    doubtful you have a syntax error - which is all we can see in the post.

    so is the nonworking field actually a lookup field in the table? ..doubtful but just a thought.....if it were then what you see in the table could differ than what is actually bound.....

    a sanity check is to back off - not use the existing syntax at all - make a simple UpdateQuery using query design - and do a manual try of it - and then build from there....you might find something along the way.....

    hope it helps a little....

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    can you supply a sample database?

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

Similar Threads

  1. Works in one database, not a new one
    By Lorlai in forum Programming
    Replies: 3
    Last Post: 06-27-2011, 10:47 AM
  2. Update 2 tables with one Update Query
    By Douglasrac in forum Queries
    Replies: 4
    Last Post: 04-14-2011, 08:33 AM
  3. db: some records works other not...
    By bobrock4 in forum Access
    Replies: 1
    Last Post: 12-16-2010, 09:17 AM
  4. CrossTab query works intermittently
    By mlcohenaz in forum Queries
    Replies: 1
    Last Post: 06-01-2010, 09:23 AM
  5. Update Query- selective update?
    By stephenaa5 in forum Queries
    Replies: 1
    Last Post: 10-29-2009, 11:15 AM

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