By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

Public variables: memorized values

P: 15
Hi everyone!

I have defined 3 public variables:
Expand|Select|Wrap|Line Numbers
  1. Public OldCompany As Variant
  2. Public OldLast As Variant
  3. Public OldFirst As Variant
A procedure defines those variables:
Expand|Select|Wrap|Line Numbers
  1. OldCompany = !Company
  2. OldLast = ![Last Name]
  3. OldFirst = ![First Name]
Now I would like to retreive those values for the variables in another procedure, in another form:
Expand|Select|Wrap|Line Numbers
  1. With rs1
  2.       .Index = "PrimaryKey"
  3.       .Seek "=", OldCompany, OldLast, OldFirst
For some reason, VB tells me those variables are empty, although, they should have been defined by the other procedure.

Could someone help me please?
Thank you!

Philippe
Aug 13 '08 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,607
  1. Are the Variables Declared in a Standard Code Module and not a Form or Report Module?
  2. Is the Procedure defining those Variables executed before an attempt is made to retrieve their values?
Aug 13 '08 #2

P: 15
I had them defined in the standard code module, but I overlooked that I had also defined them as a dim variable in the code of my private procedure. That ofcourse is the reason why it didn't work. It all works perfectly fine now.

Thank you.

Philippe



  1. Are the Variables Declared in a Standard Code Module and not a Form or Report Module?
  2. Is the Procedure defining those Variables executed before an attempt is made to retrieve their values?
Aug 13 '08 #3

ADezii
Expert 5K+
P: 8,607
I had them defined in the standard code module, but I overlooked that I had also defined them as a dim variable in the code of my private procedure. That ofcourse is the reason why it didn't work. It all works perfectly fine now.

Thank you.

Philippe
Gald you figured it out, PhilippeM. Procedural Level Variable Declarations will always override Public Declarations.
Aug 13 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.