L
Linda
I would like to run the code in a form based on the answer in the second
form. On the first form (CDM) the user would select a command button saying
they want to run this option but only for a specific department. The code in
the CDM form would then open a department form (TESTDEPT) where they could
select the department from a list. I want this value saved and passed back
to the the CDM code to finish the process. So far I get the second form to
open and assign the correct value but I can't get the value to go back to the
CDM code. I have tried several different directions. The code below is
where I am at right now. Any help would be greatly appreciated.
In the first form (form_CDM) I have the following code:
Private Sub cmdCANbyDept_Click()
' ask for the dept and then display a query based on that dept
Dim strFilter As String
Dim strDocName As String
DoCmd.OpenForm "testdept", acNormal, , , , acDialog
strFilter = "[department]= '" & strSelectDept & "'"
strDocName = "dstCANs"
DoCmd.OpenForm strDocName, acFormDS, , [strFilter], acFormEdit,
acWindowNormal
End Sub
In the second form (form_testdept) I have the following code:
Option Compare Database
Public strSelectDept As String
Private Sub cmdSelectDept_Click()
strSelectDept = ""
strSelectDept = lstSelectDept.Value
DoCmd.Close
End Sub
form. On the first form (CDM) the user would select a command button saying
they want to run this option but only for a specific department. The code in
the CDM form would then open a department form (TESTDEPT) where they could
select the department from a list. I want this value saved and passed back
to the the CDM code to finish the process. So far I get the second form to
open and assign the correct value but I can't get the value to go back to the
CDM code. I have tried several different directions. The code below is
where I am at right now. Any help would be greatly appreciated.
In the first form (form_CDM) I have the following code:
Private Sub cmdCANbyDept_Click()
' ask for the dept and then display a query based on that dept
Dim strFilter As String
Dim strDocName As String
DoCmd.OpenForm "testdept", acNormal, , , , acDialog
strFilter = "[department]= '" & strSelectDept & "'"
strDocName = "dstCANs"
DoCmd.OpenForm strDocName, acFormDS, , [strFilter], acFormEdit,
acWindowNormal
End Sub
In the second form (form_testdept) I have the following code:
Option Compare Database
Public strSelectDept As String
Private Sub cmdSelectDept_Click()
strSelectDept = ""
strSelectDept = lstSelectDept.Value
DoCmd.Close
End Sub