Incrementing field in forms only when opened

If in the same module and declared in the declarations section, whether it be Dim, Private or Public, all routines or functions can access it.

But since you mentioned in one of your post that it can be used anywhere in the project I wouldn't argue with your Public.
 
You are absolutely correct, I was thinking of declaring it in the Load event with Dim.
Can I put that down to a Senior moment. :o

Brian

PS when ever I have used Public variables I have declared them in a separate module called , that's right PublicVariables. That way they can be checked on before the same name is used elsewhere, of cause you could prefix them with say pub but names can get long and I'm a slow poor typist.
 
Ok, at first I was gonna respond (whiny voice of course) "brian it isn't working", but then I saw you posted again and when I tried that, as you already knew it would, it worked!!
Brian, I thank you for stepping in. I see now what vba was trying to tell me to do. These modules get me very confused, as you both can see...
I see that it is set that when I click my mouse in the box it populates that number. Here is my question though. The form is set up in data sheet view when it opens. (my first time using a macro, and it worked!!) So pretty much we just tab through the form itself. Is there a way it can be done that when I tab into that box and then tab to the next one it populates so that I don't have to mouse click it?
And just a question out of curiousity. In these formulas in the modules, what is that "me" implying? I don't understand that at all!!
 
You're a senior citizen, you're allowed! :)

Interesting approach declaring all your variables in a separate module.
 
Only Public Variables
For example a clientid it may be required in many different modules on data entry if say its a benefits check, I worked in a charity. Oh and to own up it was Pat Hartman who put me onto that, she was my heroine when I started out. If you are going to use Public variables having them all in one place makes checking weird happenings easier.

Brian
 
I see the point. For me I prefer having my public variables in the module to which it relates. Just my style I guess.
 
Back to the original poster, sorry we nearly hijacked your thread.

Briefly the me. tells Access to use the current object ie Form in this case , the alternative would be Forms!formname! controlname.
When you enter Me. the software's intellisense kicks in and you are presented with a dropdown of such things as all the control names, and label names, on the form which avoids typos as you just click the one you require.

maybe another event would work, I like the click it is a positive action.

In design view of the datasheet select the control and then list the propertis in there you will see other events listed, you could experiment.

Brian
 
Might I add....

You are all Geniuses in my book!!!

You were right, I was able to change it. And now it works when I tab over...
No worries of the High Jacking, someday maybe someone will learn from it!

Again, my deepest Thanks in helping me with this!!
 
We are all happy to help, glad we (all 3) got it how you want it.

brian
 

Users who are viewing this thread

Back
Top Bottom