Re: Having trouble using Public Variables please Help
Originally Posted by Jon123
I need to open a form to display a bmp picture. There are several different bmp so they are stored in a table. I have different forms where I want to pull the bmp's from so in order to make the query work I was going to use a couple of Variables in order to do this so that I would not need to create many different forms.
So what I have so far is
Option Compare Database
Public MyVariable1 As String
Public MyVariable2 As String
Now on a form I have a command button and in the onclick property I have
Private Sub form1_Click()
MyVariable1 = "value 1"
MyVariable2 = "value 2"
now on Frmtwo I have many more command buttons that a user can select which opens other forms and in the Record Source of these other forms I have it set to the query. So in the criteria field on the query I want to have = [MyVariable1] and =[MyVariable2] Now I know this won't work so I need to creat a function to set the variables and then a function to get the variables is this correct? Does anyone have any examples as to how to do this?
thanks for your time
Are the Public Declaration statements contained in one of the VB Modules behind one of your forms (Form1, Form2, etc.) or are they in their own separate Module? I believe that they need to be in a separate Module that is not associated with any form. I like to make a separate module for my public declarations.
No one is expected to know everything and we can all learn from each other if we try.
This forum is about taking the next step (or perhaps the next two steps) toward becoming a better Access programmer, and the AWF Forum Members will help you on your journey.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.