Results 1 to 3 of 3
  1. #1
    sjacksontx is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    7

    Create a macro using if then statement to update a table

    I'm not sure where this question should be. I have a form (FOM) that uses a table (fom sum tbl) for it's record source. I want to create a macro or function (not at all sure how to write a function) that updates the fom sum tbl field [sponsortype] if the field [total amt] on fom sum tbl > 0 and < 25 then sponsortype = "Donation", Or if [total amt] > 24 and [total amt] < 50 then [sponsortype] = "Bronze". I know I could make several different queries that update the table but I was trying to not have to make that many queries (I have more conditions than above) and then have the macro open and close each query.



    Can anyone help

    THanks a bunch.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    in the macro , put update queries, each represents an 'if' statement. (there is no IF ...each has a different criteria for sponsortype.)

    Qry1 = update sum tbl > 0 and < 25 where sponsortype = "Donation"
    Qry2 = update sum tbl [total amt] > 24 and [total amt] < 50 where sponsortype = "Bronze"

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I don't use macros - too limiting. (and I can't understand them)

    So here is a demo that uses a table to store the different sponsor levels. The advantage of the table is that you can change the Sponsor levels and the minimum and maximum amounts. And you don't have to create a ton of queries

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

Similar Threads

  1. SQL statement UPDATE table issue
    By gori1084 in forum Forms
    Replies: 15
    Last Post: 06-11-2014, 08:45 AM
  2. Replies: 7
    Last Post: 05-15-2014, 12:03 AM
  3. Replies: 2
    Last Post: 12-20-2011, 07:33 AM
  4. Update statement with linked table join
    By Guigui in forum Queries
    Replies: 6
    Last Post: 09-17-2010, 04:47 AM
  5. update table in loop based on IF statement
    By LALouw in forum Access
    Replies: 0
    Last Post: 07-26-2009, 08:46 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