Remembering if a checkbox has been clicked in a form

arclight

Registered User.
Local time
Today, 10:48
Joined
Mar 2, 2013
Messages
13
Hi

Something that's proving to be a little tricky. Here's the scenario:

I have a table of Clients, each of which can have zero or more Contacts. Clicking the Contacts button on the Client form opens a pop-up form that displays the Client's Contacts.

Each Client can have a default Contact, indicated by a DefaultContact checkbox on the Contact form. If the user checks this checkbox, I want to run a piece of code that checks whether any of this Client's Contacts are already set as default and, if so, warns the user before proceeding. If the user goes ahead, 'default' status is assigned to the current Contact & removed from the other.

It seems to me that the obvious place to do this is on the Contact form's BeforeUpdate event, when the record is being saved. However, it's only necessary to do this when the DefaultContact checkbox has been clicked. But there's no 'Dirty' flag for checkboxes & the only way I can think of is to set a global (within the scope of the form) variable and get the BeforeUpdate code to check it before running my 'Default Contact' code above.

It seems clumsy and I'm wondering if any of you more experienced Access programmers know of a better way to do this.

Thanks
 
Can't you do it on the checkbox BeforeUpdate event?
 
Hi JHB

Thanks for your reply.

That's what I did have, but that introduced a problem:

The form also has a Cancel button. If Contact1 is currently the default contact and the user sets the default contact for Contact2, this will remove 'default' status from Contact1 (after a warning message). If the user then changes their mind & clicks Cancel, I'd have to reinstate 'default' status to Contact1 - in other words, I'd have to remember that Contact1 had 'default' status removed while processing the Cancel event in order to put everything back as it was.

It's cleaner not to make any changes to other records until the record is actually being saved. I hope that makes sense - the issue is more complicated than it first seems.

Where in Jutland are you? I was teaching a course in Haderslev in May and got to drive there & back from Copenhagen across the Storebaelt - really nice!
 
In the Before_Update run an update query to set ALL defaults for contacts to False (No).
 
... It's cleaner not to make any changes to other records until the record is actually being saved. I hope that makes sense - the issue is more complicated than it first seems.
Another way to do it, is running a query to check if default contact change, when the Contact form is getting updated/closed.

Where in Jutland are you? I was teaching a course in Haderslev in May and got to drive there & back from Copenhagen across the Storebaelt - really nice!
I live at the west coast of South Jutland, Haderslev lies to the east of South Jutland, about 50 km from where I live.
Sorry for asking - what do you teach, (and where do you live)? :)
 
The global variable solution works and it's not as messy as I thought - I have an aversion to globals & avoid them as much as possible.

I am originally from Dublin but I've lived in Edinburgh for the last 25 years. My background is originally software development but I've been doing more IT support for Server2008/Win7 lately - and some small-scale Access database work s you can see. I teach Win7 deployment & maintenance for a training company called Learning Tree.

How about you?

Patrick
 
I just got retired for a par month ago, so plenty of sparetime, where I can do what I want - I've look forward to this for years, and now hip, hip - hurray. :D

Before that I've worked at a Roof-window's factory in the Quality department, at last most with ISO-standards and Raw-Wood CoC, (FSC and PEFC).
 

Users who are viewing this thread

Back
Top Bottom