How do I make a variable both public and static?
At least I think that is what I want to know - let me explain.
I have a form that I get to from a button on another form. The following code is on the button click event and works fine,
Private Sub Special_Needs_CmdBtn_Click()
On Error GoTo Err_Special_Needs_CmdBtn_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Special_Needs"
If Me.ARCHIVE = True Or Me.ARCHIVE2 = True Or Me.ARCHIVE3 = True Then
MsgBox "This student is archived"
Exit Sub
Else
stLinkCriteria = "[STUDENT_NUMBER]=" & "'" & _
Me![STUDENT_NUMBER] & "'"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_Special_Needs_CmdBtn_Click:
Exit Sub
Err_Special_Needs_CmdBtn_Click:
MsgBox Err.Description
Resume Exit_Special_Needs_CmdBtn_Click
End Sub
The second form closes on a timed event to stop people leaving it open when they move away from their PC. This bit also works fine.
The problem I'm having is setting up a quick (one click) way of getting back to the same record on form 2 without reopening it form one.
What I am trying to do is grab the value of the student number off form 2 as it closes - hold this value in a static state and then pass it to a button - using the same code as above but substituting the value of the variable for the second instance STUDENT_NUMBER - ie. Me![STUDENT_NUMBER] in the code sample above.
I have delared a public variable called KEEPHOLD which grabs the value of the student number as the form closes. I tested this by putting in a message box that used the code:
Msgbox " you are passing number" & KEEPHOLD
This popped up a message with the correct number so going out is OK but comming back in the value of KEEPHOLD is empty.
HOW - WHERE do I keep hold of the value to use again.
Many thanks...... Sprocket
At least I think that is what I want to know - let me explain.
I have a form that I get to from a button on another form. The following code is on the button click event and works fine,
Private Sub Special_Needs_CmdBtn_Click()
On Error GoTo Err_Special_Needs_CmdBtn_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Special_Needs"
If Me.ARCHIVE = True Or Me.ARCHIVE2 = True Or Me.ARCHIVE3 = True Then
MsgBox "This student is archived"
Exit Sub
Else
stLinkCriteria = "[STUDENT_NUMBER]=" & "'" & _
Me![STUDENT_NUMBER] & "'"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_Special_Needs_CmdBtn_Click:
Exit Sub
Err_Special_Needs_CmdBtn_Click:
MsgBox Err.Description
Resume Exit_Special_Needs_CmdBtn_Click
End Sub
The second form closes on a timed event to stop people leaving it open when they move away from their PC. This bit also works fine.
The problem I'm having is setting up a quick (one click) way of getting back to the same record on form 2 without reopening it form one.
What I am trying to do is grab the value of the student number off form 2 as it closes - hold this value in a static state and then pass it to a button - using the same code as above but substituting the value of the variable for the second instance STUDENT_NUMBER - ie. Me![STUDENT_NUMBER] in the code sample above.
I have delared a public variable called KEEPHOLD which grabs the value of the student number as the form closes. I tested this by putting in a message box that used the code:
Msgbox " you are passing number" & KEEPHOLD
This popped up a message with the correct number so going out is OK but comming back in the value of KEEPHOLD is empty.
HOW - WHERE do I keep hold of the value to use again.
Many thanks...... Sprocket