Checking multiple unbound controls on the form

valeryk2000

Registered User.
Local time
Today, 16:55
Joined
Apr 7, 2009
Messages
157
1) We are using SQL Server (all tables and queries, e.g. stored procedures) are on the server side - NO LINKED TABLES! All tables and st. procedures run via ADO.
2) On the client side we have forms with unbound controls, populated by recordsets.
3) Users select individual records clicking a listbox.
3) If any changes are made - then we need to update the records in SQL Server tables.
4) There is a button Save Changes on the form that would do the updating.
5) However the user might forget to click this button and select next record thinking that the changes are saved automatically (which would be the case if it was an access database where tables are linked to controls with dynasets).
6) We need to alert users with pop-up message box Do you want to save changes? every time s/he selects a new record from the list.
7) HOWEVER, if the user was just looking, without clicking any of the controls on the form this pop-up does not make sense and annoy our users.
8) SO WE NEED A WAY TO check if controls on the form were clicked (at least!).
9) We cannot use DIRTY property - it works only when the data in the tables are changed.
10) One of the way to do so is to use a flag variable that would be set to TRUE when any of the controls is clicked. So ... it takes a lot of code.
11) May be somebody can suggest a better solution?
Thanx
 
Hi,

Here is a suggestion:

After you populate all your controls, you could take a "snapshot" of their values, like looping through each of them and keeping their values in a array. Then, when selecting a new record do that loop again and check if any value has changed.

That would not require much coding, but there might be some better solutions out there...

HTH

Simon B.
 
Well... YOU ARE RIGHT! I can use a recordset instead of array... Let me think of it...
 
Well, presumably you're populating the form from a recordset.
Then you close it?
So just don't close it. It's then available for subsequent comparison.
(Since you're using an ADO recordset then I'd suggest it be disconnected, if it isn't already).

Equally you can monitor your controls quite simply, either with a function called from each control or a class to add all controls to a collection.
OK the class counts as a bit of code, but once written can apply to any such form trivially.

Cheers.
 
Thanks. I'll try this approach. The final task will be more complicated since there are subforms that also can be changed ...
 
Thanks. I'll try this approach. The final task will be more complicated since there are subforms that also can be changed ...

Yes, when you go the route of unbound forms you basically have to code for EVERYTHING because you have taken the majority of what Access is, out of the equation. If you want to go that route, you have to know it will be at least 10 times as much to code what Access normally does for free for you. Just something to know.
 

Users who are viewing this thread

Back
Top Bottom