Event Loops

zim_ulator

Registered User.
Local time
Today, 14:04
Joined
Dec 7, 2004
Messages
12
Hello all,

I'm new-ish to Access, having developed in FoxPro some time ago, I keep finding analogies and parallels between the two to the extent that I'm developing a relational database.

I've decided to make my forms to be similar in functionality to my old work. With FP I used TRO and CodeBook templates, which make a complex application easier to develop by coding functionality into an event loop for me. So, now I'm trying something like this with Access, and I wonder if anyone's already done this.

At this point, I've got a form with an event loop in a module. This loop handles Add, Edit, Save, Cancel, and Delete record functions, and moving the record pointer to First, Previous, Next, and Last record; events are triggered by the click event on buttons in the form.

So far, everything works well except I'm getting hung up with a "Cancel" button which can undo an entry or edit. I think I'm onto a solution, and I'll post details later.

Mostly I'm doing this because I hate the way data is presented in forms for data entry: IMHO, the default behavior of adding records, for example, is to dangerous. With the app I'm developing now, I can't have my users easily change or delete data without safeguards. Any pointers, comments, wit, or satire would be appreciated; in other words, has this been done to death already?

Zim
invading an earth near you
 
Last edited:
So far, everything works well except I'm getting hung up with a "Cancel" button which can undo an entry or edit.

Is this hang-up conceptual or practical? If practical, what is the problematic behavior? Error message, maybe? Or unexpected action?

Conceptually, a Cancel can be done a couple of ways. I just used the button wizard to generate an UNDO operation for me, then customized it. I would advise looking at the code generated by the wizard as a starting point. (But I never leave the wizard's code as-is. MS Wizards are DUMB.)

Finding related entries to Cancel form-based events appears in this forum quite often. A good search should find what you want based on keywords "Cancel" or "UNDO" The search to unearth what you want should be at least SLIGHTLY smaller than the Big Dig.
 
Zim,
You are making way too much work for yourself. There have been a number of posts recently discussing bound vs unbound forms. You can do just about anything you want with a bound form as long as you understand the event model. You will write far less code and have far less code to debug if you use bound forms with small bits of code in the correct events.
 
The_Doc_Man said:
Is this hang-up conceptual or practical? If practical, what is the problematic behavior? Error message, maybe?.....

The search to unearth what you want should be at least SLIGHTLY smaller than the Big Dig.

The problem was that I couldn't reliably trigger my Undo code; the solution lay in the fact that a NULL cannot be used in a comparison. I found a function which helped me understand this, so now all of my code runs as expected.

The big dig? Argh! It's a travesty!
 
Pat Hartman said:
Zim,
You are making way too much work for yourself. There have been a number of posts recently discussing bound vs unbound forms.

Pat,

Thanks for your input. As far as I know, I am using bound forms. Did I imply that I'm using unbound?

Denis
 
Code:
[b]Me.Undo[/b]

This will act as a cancel for saving a record.
 
At this point, I've got a form with an event loop in a module. This loop handles Add, Edit, Save, Cancel, and Delete record functions, and moving the record pointer to First, Previous, Next, and Last record; events are triggered by the click event on buttons in the form.
- sure sounds like you're writing code that has already been written and debugged.

If you need to cancel an update, do it in the BeforeUpdate event of the FORM. Use:
Cancel = True

The expression - Me.Undo - will remove all data entry or pending changes from the form. This is somewhat draconian if all you want the user to do is to correct one field.
 

Users who are viewing this thread

Back
Top Bottom