A better "Better Mousetrap"?

BrokenBiker

ManicMechanic
Local time
Today, 15:37
Joined
Mar 22, 2006
Messages
128
Like many on this board I've used the mousetrap by GHudson. However, I have two subforms in the main form. This has created a lot of saving. There are three diferent areas to save in now.

One thing I did to reduce the number of times a user has to save his/her records is to incorporate a "new record clause."

Basically:
Code:
If Me.NewRecord Then
     Exit Sub
Else
     <mousetrap code here>
End If

This has helped considerably, but I've been trying to find ways to incorporate all three 'saves' (the main form and both subforms) into one function. First, I tried to bypass or transfer the Before Update function of the subforms to the main form, but that's proven ineffective.

The next trick was to change the code a little. Instead of trapping the mousetrap in the subforms' Before Update function, I used it to change a field in the main form hoping that this would "dirty" the main form--thereby enacting the main form's mousetrap. No luck there either, I'm afraid.

I tried again to use the subform's Before Update mousetrap to change the main form by using:

Code:
Forms![MainFormName].Dirty = True

only to receive errors.

I've pretty much decided that I'm not gonna figure this one out on my own. I'm hoping someone might have some insight on this. I'm afraid that because of how forms & subforms interact w/ their own Before Update events that this isn't going to be possible, but I'm still hopeful!

Any help is greatly appreciated, even if it's only to tell me that I'm way off track!;)
 
Because each bound form will save a record when you leave the form (and that is a non-negotiable feature of Access), if you want to update all forms at the same time, you will need to use unbound forms and write code to save everything (not a small matter).
 
Have you tried the MouseHook.dll file to prevent the mouse scrolling?
 
boblarson said:
Because each bound form will save a record when you leave the form (and that is a non-negotiable feature of Access), if you want to update all forms at the same time, you will need to use unbound forms and write code to save everything (not a small matter).

That's kinda what I was afraid of....I haven't quite given up on it yet, though. (I'm kinda stubborn that way.) I'm hoping that I can find a way to use a field value (whether from a bound or unbound field) as a flag to perform essentially the same as the mousetrap. It might turn out to be a quest for the Holy Grail, so to speak.

I had used the mousehook.dll before and it worked fine. I don't use it anymore in this database. I'll take a look at the mousehook example to see if maybe I can use it to run this the way I want it.
 
Well, I checked out the "mousehook" file, but I don't think it's gonna really help out. The problem isn't so much trapping them in the record, it's forcing the user to save/undo changes only once, as opposed for each section of the form.

I know that you can change the value of a field (bound or unbound) in the parent form when you make changes to the child form, but I'm having troubles catching this change in the main form's Before Update event...assuming that's the proper place to capture it. If I can do that, I should be able to run a bit of code to save all sections of the form similar to this:

Code:
me.fieldname.setfocus 
docmd runcommand acCmdSaveRecord
forms![MainForm]![SubForm]![FieldName].setfocus
docmd runcommand acCmdnSaveRecord


It seems like it'll work, but I can't quite trap things in the main form from the subforms....Hmmm...
 

Users who are viewing this thread

Back
Top Bottom