If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
Now we are on to Variables.
At the top of one of my form modules I have ....
Option Compare Database Option Explicit Private strItem As String Am I correct in thinking that I can now use strItem in any procedure within that specific form module? FOr instance if strItem is defined as "TeeSee" in OpenForm then it would still be the same value on a cmdClick event on the same form. Are there any tricks to doing so 'cos I can't get it to work out. Thanks |
#2
|
|||
|
|||
Now we are on to Variables.
"TeeSee" wrote in message
... At the top of one of my form modules I have .... Option Compare Database Option Explicit Private strItem As String Am I correct in thinking that I can now use strItem in any procedure within that specific form module? FOr instance if strItem is defined as "TeeSee" in OpenForm then it would still be the same value on a cmdClick event on the same form. Yes. Are there any tricks to doing so 'cos I can't get it to work out. You'd have to show us exactly what you coded. One possible error would be to *redefine* strItem in the procedures. If you Dim it at the module level, don't Dim it anywhere else in that module, or you'll just be creating a separate, local veriable of the same name, hiding the module-level one from that procedure. -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
#3
|
|||
|
|||
Now we are on to Variables.
On Jan 19, 10:11*pm, "Dirk Goldgar"
wrote: "TeeSee" wrote in message ... At the top of one of my form modules I have .... Option Compare Database Option Explicit Private strItem As String Am I correct in thinking that I can now use strItem in any procedure within that specific form module? *FOr instance if strItem is defined as "TeeSee" in OpenForm then it would still be the same value on a cmdClick event on the same form. Yes. Are there any tricks to doing so 'cos I can't get it to work out. You'd have to show us exactly what you coded. *One possible error would be to *redefine* strItem in the procedures. *If you Dim it at the module level, don't Dim it anywhere else in that module, or you'll just be creating a separate, local veriable of the same name, hiding the module-level one from that procedure. -- Dirk Goldgar, MS Access MVPwww.datagnostics.com (please reply to the newsgroup) Thanks Dirk ..... I had four Dims. One at the module level, two at the sub level and me! |
#4
|
|||
|
|||
Now we are on to Variables.
Yes, yes, and what are the symptoms? - in that order.
Now I suspect the confusion relates to your statement: '.. if strItem is defined as "TeeSee" in OpenForm ...' What exactly do you mean by that? If you mean that you have a code line similar to the following in the Open event Private Sub Form_Open(Cancel As Integer) strItem = "TeeSee" End Sub then everything should work just fine, although you might want to consider defining the string as a constant in the declaration section if its value never changes. If however you are referring to a DoCmd.OpenForm then short of passing "TeeSee" as OpenArgs I can't see how you are managing this. Rod |
#5
|
|||
|
|||
Now we are on to Variables.
If you want to use the variable in different forms then you will have
to hold it in a separate module. If it is local to one form then declaring it at the top will be fine. For FREE Access ebook and videos click here http://access-databases.com/ebook On 20 Jan, 00:51, TeeSee wrote: At the top of one of my form modules I have .... Option Compare Database Option Explicit Private strItem As String Am I correct in thinking that I can now use strItem in any procedure within that specific form module? *FOr instance if strItem is defined as "TeeSee" in OpenForm then it would still be the same value on a cmdClick event on the same form. Are there any tricks to doing so 'cos I can't get it to work out. Thanks |
Thread Tools | |
Display Modes | |
|
|