0

I have created a database in Access 2013 to track donations and solicitation for an auction. My prospects are set up in one table/form with an available column to note whether or not they participated this year.

Once an item is sent in, I log that item in a linked "Donations" form that calls out its donor.

Is there a way to automatically check the participation checkbox in the Prospects form once a donation has been entered in the Donations form?

I feel like I can imagine a somewhat simple piece of JS that could take care of this, but don't know Access well enough to accomplish the task in that program.

1 Answer 1

0

A more elegant solution probably exists with VBA, but I will show you one way to do it with macros:

First create a "Named Macro" in your table that tracks Donors, and we'll call it UpdateParticipation. Then create two parameters for the macro - first one is prmAction and that will determine if you inserted or deleted an item from your donation table. Second parameter is prmDonorID and that will identify which record in the table to update the status for.

The named macro will check the participation box if a donation is added, and uncheck the participation box if a donation is deleted. The macro will look like this:

If [prmAction]="Inserted" Then
    Look Up A Record In DonorsTable
    Where Condition = [DonorsTable].[ID]=[prmDonorID]
    Alias
    EditRecord
    Alias
        SetField
        Name DonorsTable.Participated
        Value = True
    End EditRecord
Else If [prmAction]="Deleted" Then
    Look Up A Record In DonorsTable
    Where Condition = [DonorsTable].[ID]=[prmDonorID]
    Alias
    EditRecord
    Alias
        SetField
        Name DonorsTable.Participated
        Value = False
    End EditRecord
End If

Now whenever you are in the DonationsTable and insert/delete a record, you want to trigger the named macro.

So in DonationsTable create an After Insert Event that looks like this:

RunDataMacro
    Macro Name DonorsTable.UpdateParticipation
Parameters
    prmAction = "Inserted"
    prmDonorID = [DonationsTable].[DonorID]

When you delete a record it's a little trickier - if you are deleting the second donation from a donor, they are still participating so you don't want to uncheck the box in DonorsTable. So create an After Delete Event that looks like this:

Look Up A Record In SELECT DonationsTable.DonorID FROM DonationsTable;
    Where Condition = [DonorID]=[Old].[DonorID]
    Alias
    StopMacro
RunDataMacro
    Macro Name DonorsTable.UpdateParticipation
Parameters
    prmAction = "Deleted"
    prmDonorID = [DonationsTable].[DonorID]

That will have you covered if you insert or delete a donation. You will want to create a similar setup if an existing record in DonationsTable is edited, where the DonorID is changed from one to another.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, Dave. I understand how the code you're setting up works, but I'm a little confused on how to implement this. Many of these options don't exist in my Macro Builder, i.e. "Look Up A Record", "Alias", "[prmAction]". I'm BRAND NEW to this and apologize if I'm missing something that's very basic.
No worries at all - took me a while to figure things out too. Those options you aren't seeing are available in the data macro builder. Data macros are special in that they're tied to events that happen in a table and are restricted to actions that involve table data. So open up your table that tracks donors and there should be a tab for table tools and "before events" or "after events". Choosing an "after insert" event will allow you to create a data macro. See if you can find that then follow the steps above. Keep me updated - Dave
Thanks, @Dave. I'm able to access all of that now. I'll work on it and get back to you. I'm a little worried that my Donor column in my Donations table (which is currently set to house BOTH the donor's name and company) may not link correctly to the Donor ID, but I'll give it a shot. Much appreciated.
Okay, Dave. It seems to be working. It will get tested over the course of the next few weeks as new items come in and out. THANK YOU for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.