OK Ken here is the code behind the two modules. As you can see I an not
"re-DIMing the variables. I read your responce to Jeff but did not
understand what you meant by "qualified"
Please help.
-----------------------------------------------------------------------------
Public strNewContestName As String
Public intNewContestID As Long
Option Comp are Database
-------------------------------------------------------------------------------
Private Sub Command143_Click()
On Error GoTo Err_Command143_Click
' Test to see if this event is offered in the other contest
intNewContestID = DLookup("[LinkTo ID]", "[Contests]", _
"[Contest ID] = Forms![Team Entry]![Contest Ident]")
intNewFeeID = Nz(DLookup("[Fee ID]", "[Team Fees]", _
"([Contest ID] = intNewContestID) and " _
& "([Category ID]= Forms![Team Entry]![Category ID])"), 0)
strNewContestName = DLookup("[Contest Name]", "[Contests]", _
"[Contest ID] = intNewContestID")
' If not send message and exit
If intNewFeeID = 0 Then
MsgBox ("You can not move this team deffnition to the " &
strNewContestName _
& " contest because " & [Combo42].[Column](2) & " is not offered in
that contest")
Exit Sub
End If
MsgBox (intNewContestID & ", " & intNewFeeID & ", " &
strNewContestName)
'Open the switch team form
DoCmd.OpenForm "Team Switch", , , "[ID]=" & Me![ID]
Exit_Command143_Click:
Exit Sub
------------------------------------------------------------------------------------
MSGBOX shows 12, 243, Open 2006
Form B is opened and click on the SAVE button runs this code.
MSGBOX shows , ,
------------------------------------------------------------------------------------------------
Private Sub Command6_Click()
On Error GoTo Command6_Click_Err
MsgBox (intNewContestID & ", " & intNewFeeID & ", " & strNewContestName)
' Zero to Fee ID
Forms![Team Switch]![Fee ID] = intNewFeeID
Ken Snell (MVP) said:
Steve
I may be remembering incorrectly, but I thought that only those
variable
defined in code module (and not in forms & reports) were treated as
"share-able" within the .mdb file.
They can be shared, but they must be qualified by the form's module
reference (just as one would do with calling a public procedure inside a
form's module), and of course the form must be open at the time that
another
module wants to read the values. (The public variable essentially is a
read/write property of the form.)
But rather than passing variable values from form to form, why not have
form2 "look at" form1 and get its values? Or even, if you MUST pass,
use
the OpenArgs property and pass in values via OpenArgs.
Or write the value into a hidden textbox on the form and read the value
from
that textbox.