Results 1 to 4 of 4
  1. #1
    asmith is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    26

    Search for Record, create new if not existant


    Hey everyone,

    I'm trying to create a macro to execute after a form text box updates. I'm aware of how to attached the macro to the "After Update" event but i'm having trouble with the macro itself.

    What i'm looking to do is take the value of cell that has just been updated and use that for the search criteria to look at the history table and search for that value in a specific column. If the value exsists, do nothing, if it doesn't exsist create a new record and populate the value using the search criteria.

    The only start i have is i believe i've found the code to create a new record which i think is : "DoCmd.GoToRecord , , acNewRec"

    Any help or references would be greatly appreciated.

    Thanks!
    Andrew

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    I don't use macros, but I assume you can put a DCount() in the Conditions box and only perform the action if the count = 0.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    asmith is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    26
    Thanks for the tip pbaldy

    I was able to encorporate the DCount feature in some VBA and it worked perfectly.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Excellent, glad it worked for you. I think you'll be happier with VBA than macros in the long run anyway (though they have improved them in 2010).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. create search form
    By Balen in forum Forms
    Replies: 0
    Last Post: 08-22-2010, 01:01 AM
  2. not able to search record
    By shoukat1234 in forum Access
    Replies: 0
    Last Post: 06-15-2010, 03:53 AM
  3. Record search
    By dhammikai in forum Forms
    Replies: 3
    Last Post: 04-05-2010, 10:19 AM
  4. Create combo search form in subform
    By grant.smalley in forum Forms
    Replies: 6
    Last Post: 02-19-2010, 04:37 AM
  5. How do I create a name search ?
    By nightviperdark in forum Access
    Replies: 1
    Last Post: 11-23-2009, 09:53 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