I am trying to pass the following variables between multiple forms
CurrentForm
PreviosForm
NextForm
ProjectID
The intent is to simplify the code for my Back button, and "Open next Form" button. The next form typically is opened with a where projectID = projectID from current form.
I have tried to list the variable in the public section of my first form but that does not seem to work.
Mainly the form variables are to track navigation through the application screens.
Thoughts, suggestions, examples???
Below is the code from one of my forms:
Private Sub cmd_BackToProjectList_Click()
On Error GoTo Err_cmd_BackToProjectList_Click
Dim stLinkCriteria As String
stLinkCriteria = "[ProjectID]=" & "'" & Me![ProjectID] & "'"
DoCmd.Close acForm, CurrentForm, acSaveNo
DoCmd.OpenForm PreviousForm, , , stLinkCriteria
CurrentForm = PreviousForm
Exit_cmd_BackToProjectList_Click:
Exit Sub
Err_cmd_BackToProjectList_Click:
MsgBox Err.Description
Resume Exit_cmd_BackToProjectList_Click
End Sub
Private Sub cmd_GoToDeliverables_Click()
On Error GoTo Err_cmd_GoToDeliverables_Click
Dim stLinkCriteria As String
NextForm = "Frm-ProjectDeliverableList"
stLinkCriteria = "[ProjectID]=" & "'" & Me![ProjectID] & "'"
DoCmd.Close acForm, CurrentForm, acSaveNo
PreviousForm = CurrentForm
DoCmd.OpenForm NextForm, , , stLinkCriteria
CurrentForm = NextForm
Exit_cmd_GoToDeliverables_Click:
Exit Sub
Err_cmd_GoToDeliverables_Click:
MsgBox Err.Description
Resume Exit_cmd_GoToDeliverables_Click
End Sub
CurrentForm
PreviosForm
NextForm
ProjectID
The intent is to simplify the code for my Back button, and "Open next Form" button. The next form typically is opened with a where projectID = projectID from current form.
I have tried to list the variable in the public section of my first form but that does not seem to work.
Mainly the form variables are to track navigation through the application screens.
Thoughts, suggestions, examples???
Below is the code from one of my forms:
Private Sub cmd_BackToProjectList_Click()
On Error GoTo Err_cmd_BackToProjectList_Click
Dim stLinkCriteria As String
stLinkCriteria = "[ProjectID]=" & "'" & Me![ProjectID] & "'"
DoCmd.Close acForm, CurrentForm, acSaveNo
DoCmd.OpenForm PreviousForm, , , stLinkCriteria
CurrentForm = PreviousForm
Exit_cmd_BackToProjectList_Click:
Exit Sub
Err_cmd_BackToProjectList_Click:
MsgBox Err.Description
Resume Exit_cmd_BackToProjectList_Click
End Sub
Private Sub cmd_GoToDeliverables_Click()
On Error GoTo Err_cmd_GoToDeliverables_Click
Dim stLinkCriteria As String
NextForm = "Frm-ProjectDeliverableList"
stLinkCriteria = "[ProjectID]=" & "'" & Me![ProjectID] & "'"
DoCmd.Close acForm, CurrentForm, acSaveNo
PreviousForm = CurrentForm
DoCmd.OpenForm NextForm, , , stLinkCriteria
CurrentForm = NextForm
Exit_cmd_GoToDeliverables_Click:
Exit Sub
Err_cmd_GoToDeliverables_Click:
MsgBox Err.Description
Resume Exit_cmd_GoToDeliverables_Click
End Sub