Ok, the first thing i found out is that i should be using 'Public' instead of 'Global", so i did that. Here is what i tried to do (yes i have read as much as i could before i posted...... i promise). I set my variables in a module (not a class module) like this
-
Public ShippingType as Integer
Then i set a value to it with buttons on a popup form like this
-
Private Sub customer_Click()
-
DoCmd.OpenForm "frmshipping", acNormal, , , acFormAdd
-
ShippingType = 1
-
DoCmd.Close acForm, "frmshiptype"
-
End Sub
-
-
Private Sub transfer_Click()
-
DoCmd.OpenForm "frmshipping", acNormal, , , acFormAdd
-
ShippingType = 2
-
DoCmd.Close acForm, "frmshiptype"
-
End Sub
-
-
Private Sub vendor_Click()
-
DoCmd.OpenForm "frmshipping", acNormal, , , acFormAdd
-
ShippingType = 3
-
DoCmd.Close acForm, "frmshiptype"
-
End Sub
-
Then on the form "frmshipping" i placed in the OnCurrent Event
-
If ShippingType = 1 then
-
blah blah blah
-
end if
-
-
if ShippingType = 2 then
-
blah blah blah
-
end if
-
-
if ShippingType = 3 then
-
blah blah blah
-
end if
Then when it wasnt working properly i added this before the if/thens
Then ( i will say it this way on purpose) when i open the form the second time using Transfer (ShippingType should be equal to 2), after opening it the first time with Customer (ShippingType = 1) then i get a 1 in the msgbox. Every time i do it it gives me the value from the press before. Beleive it or not, while trying to cheat i decided to do this
- ShippingType = 1
-
ShippingType = 1
Just to see if delcaring it twice would work...... Well it didnt. Can someone please give me the tip i need to move on. I thought i had global variables figured out because this method actually worked somewhere else (summing numbers from some queries) but it doesnt seem to work here. Any help is appreciated.
Also, when a global variable is used.... is it the same for all users, or are different users able to set different values to it at the same time.
KStevens