Results 1 to 5 of 5
  1. #1
    acenumber5 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    19

    Totals (group b)y + Update query?

    I have a productvariant table that contains data like this:
    ProductID, SKU, field1, field2, etc
    1,1234,red, small
    1,1235,red, large
    1,1236,red,X-large
    2,1237,blue,small
    2,1238,blue,medium.

    So I have 1 productID with multiple Variants (different sizes)

    I'm trying to update a field for just one variant for each product ID. I don't care which one it is. I just need to make one of them the default variant by putting a "1" in one of the fields and "0" in the non default variant fields. I tried to do use the Group By function in the totals query, which will give me the out put I'm looking for:
    1,
    2,
    3, etc

    But I can't do an update query from that query.

    I know I'm going about this the wrong way. Can anyone point me in the right direction? I'm using Access 2010.
    Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I don't understand. The variant fields have text values of blue, red, small, medium, large. What field do you want to update to 1 or 0? How will that produce output of
    1,
    2,
    3,
    etc?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    acenumber5 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    19
    Thanks for the replay. Sorry, My eyes were crossed when I wrote this. The actual field I'm trying to update is the DefaultVariant field. So most Items have 3 variants -Small, Medium, Large, and I have to have one of them be the default and the rest not default. So what I really need is:
    ProductID1, Sku1, Defaultvariant= 1
    ProductID1,Sku2, Defaultvariant = 0
    ProductID1, SKu3, DefaultVariant =0

    Right now its:
    ProductID1, Sku1, Defaultvariant= 0
    ProductID1,Sku2, Defaultvariant = 0
    ProductID1, SKu3, DefaultVariant =0

    Thanks!

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    So the fields are: ProductID, SKU, field1, field2, DefaultVariant

    DefaultVariant is a text, number, or Yes/No type?

    Each ProductID will have several records. You want the record with lowest SKU to be set with DefaultVariant 1 and the others are 0?

    If DefaultVariant is Yes/No field, try:
    UPDATE Table1 SET Table1.DefaultVariant = IIf([SKU]=DMin("SKU","Table1","ProductID='" & [ProductID] & "'"),-1,0);

    Otherwise, try:
    UPDATE Table1 SET Table1.DefaultVariant = IIf([SKU]=DMin("SKU","Table1","ProductID='" & [ProductID] & "'"),1,0);
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    acenumber5 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    19
    The DefaultVariat is a number field. 1 or 0.

    I'll try your second suggestion. Thank you very very very much!

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

Similar Threads

  1. Unusual Sub Totals & Totals in Groups.
    By Robeen in forum Reports
    Replies: 12
    Last Post: 03-20-2012, 08:55 AM
  2. Replies: 5
    Last Post: 12-06-2011, 11:18 AM
  3. automatically update club members age group
    By sirnickettynox in forum Programming
    Replies: 4
    Last Post: 04-06-2011, 06:52 AM
  4. Help designing a group update form
    By 10 Gauge in forum Forms
    Replies: 22
    Last Post: 03-28-2011, 10:30 AM
  5. Group Totals in a form
    By mai1081 in forum Forms
    Replies: 1
    Last Post: 05-14-2008, 06:11 PM

Tags for this Thread

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