scottfl
11-01-2000, 08:28 AM
Can someone tell me how to pass a variable between forms? I tried setting the variable up as a public variable but when I tried to refrence it in a called form it did not work. I even tried declaring it in a module to no success. Doing that the variable was still declared but if I changed its value in form a and called it again in form b, form b's value was still 0.
Any help??
Thanks!!
Scott
Chris RR
11-01-2000, 10:11 AM
Well, here's one way:
Let's say you have fFormA and fFormB, and want to pass department id and name. You could set up fields in fFormB then set them from code in FormA:
DoCmd.OpenForm fFormB, , , , acAdd
Forms![fFormB]![txtDeptID] = Me.txtDeptID
Forms![fFormB]![txtDeptNm] = Trim$(DLookup("[DEPT_DESC]", "MYTABLE", "[ID_DEPT] = '" & Me.txtDeptId & "'"))
The fields in fFormB doesn't need to be visible, and could even be locked, and you can still use them to control your processing in fFormB.
chrismcbride
11-01-2000, 06:43 PM
Scott
In order to create a Global Variable, substitute the Dim Keyword with Public. Make your Declaraion in the General Declarations section of a Module. And away you go...
Good Luck
Chris