G’day or (o1110010
)
There are a few questions here…
Since you are using A2000 you can convert the A97 demo database, that’s one of the two main reasons I stick to A97. The other is that it has a help file system that works, not as good as the one in Borland compilers but better than later versions of Access.
Option Explicit…
Forces the declaration of variables before they are referenced, always good practice when writing code. Only reason I know for turning it off is if we get a database that has not declared variables and we don’t want to re-write it before we can compile it. Of course, if it was always on then we would not have that problem because we could not get databases written like that.
Option Compare Text…
I would not like to re-write or disagree with Michael Kaplan
in this article.
What's the difference between
Function and
Sub?
Two main differences, one of which you will be aware of, coming from “C”, one of which you will become aware of going to VBA.
In “C” a Function must return a value, a Subroutine must not return a value except by reference; both indiscretions will be picked up by the “C” pre-compiler.
In “VBA” a Function need not return a value, a Subroutine cannot return a value except by reference.
In both “C” and “VBA” arguments passed ByRef, and modified, can ‘reflect’ back to the caller.
This can become a subtle trap, which can be difficult to find, if it causes a problem
Why does a System generated Event Handler have to be a Subroutine?
Why does a User generated Event Handler have to be a Function?
I have absolutely no idea and over to Bill $x10^11 and the people at Micro$oft.
Finally, the last difference that wasn't spoken of earlier. I noticed you use ByVal strButtonName As String but Mile-O-Phile used ctl As Control. Is the difference just a DAO vs ADO thing? If not, what?
I’m not sure what you mean by the comparison here, perhaps you could please point me in the right direction. In any case it is not a difference between DAO and ADO.
I missed that when I read about the Tag property the first time. However, my help file makes it appear as if there is a space " " between the quotes. But it doesn't matter because a ZLS is never null?
Correct.
My view of the similarity between “C” and “VBA” is that a ZLS has been declared and initialized to zero length and has, the address that is, been assigned a valid value. A Null has been allocated memory space for the pointer and not initialized with the address of the data. Hence; if it contains anything at all, the address that is, it would contain junk left over from the last user of that memory space, if any.
So for every button, I need to change MyButton to the corresponding button's name being clicked. No way around that? I was hoping to have one universal call from the button where the only difference between button's would be their visual appearance, name, & Tag. No possible? Let me rephrase that.. Not the easiest way?
First thing for sure each button, or whatever, must have a unique name otherwise there is no way to reference that control and you won’t even get passed the editor.
You can reference a Control without referencing its Name but the name still needs to be unique.
Pointers to Controls “live” in an array, at run time, and can be referenced by array sub-script.
However, to reference a particular Control, or set of Controls, in that array you still need a way to make the reference unique. The system creates the array and the position of any particular control can’t be relied on.
There are a few ways to achieve that “Control Uniqueness” but would require another article to do so.
I am aware that Call SendButtonInfo(Me.MyButton) from an OnClick procedure works. I was wondering if Mile-O-Phile was referring to a macro or directly in the event portion of the button. For every button I use for this example, I will need to have a seperate procedure? If so, is there a point to mess with "Tag" in this instance?
First part of the question;
I have never been able to get that syntax to work but would appreciate any guidance.
Second part of the question;
I doubt very much if Mile-O was referring to a Macro.
My understanding of Macros is that they are like training wheels on a bicycle…
Once you have got your balance they should be dispensed with.
I think Mile-O has his balance.
Third part of the question;
Separate procedure?
Absolutely not.
I have a form with 500+ text boxes on it, one more on leap years. It’s a graphical display that has nothing to do with the underlying structure of the database. It displays some booking details of a particular unit for each day over a period of time. Display starts at the beginning of the selected year and stops at the end of the next financial year. Each box has a MouseMove, Click, and DblClick event as well as a Tag property, the Tag property has the booking ID in it.
All of the above are set in code, mainly because I’m lazy. Four parameters for each of 500+ text boxes. 2000+ parameters to possibly change manually?
Never…I’m lazy!
Lastly, what are the procedures Form_Open and MakeFunctionCall for? Can describe 'em? (After looking at them, I wouldn't think I'd need them for what I want to do.)
The Form Open event is where you set-up the code to configure your private collection. The MakeFunctionCall function helps to remove the complexity of writing code that writes code.
Above all else…have fun with Access and VBA.
Regards,
Chris.