G
Guest
What changes to the following code so it filters using the set variable.
I keep getting asked to input data for the Employer field.
The first button works so i know the variable is set.
Anyone got any ideas.
Cheers
Module code:
Option Compare Database
Global CurrentCompany As String
Option Explicit
Public Sub Set_A()
CurrentCompany = "[Employer] IN (Company A Ltd')"
End Sub
Public Sub Set_BC()
CurrentCompany = "[Employer] IN ('Comapny B Ltd', 'Company C Ltd')"
End Sub
............................................................................................................
1st Form command button:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
DoCmd.Close
Call Set_A
Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = CurrentCompany
stDocName = "frm_Employee_Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
....................................................................................................................
2nd Form command button:
Private Sub Command105_Click()
On Error GoTo Err_Command105_Click
Dim stDocName As String
Dim stLinkCriteria As String
recnum = Me.CurrentRecord
stLinkCriteria = CurrentCompany
If Len(CurrentCompany & "") > 0 Then
stDocName = "frm_Misc_Records"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acGoTo, recnum
DoCmd.Close acForm, "frm_Employee_Form", acSaveNo
Else
MsgBox "No Company Name"
End If
Exit_Command105_Click:
Exit Sub
Err_Command105_Click:
MsgBox Err.Description
Resume Exit_Command105_Click
End Sub
.....................................................................................................
I keep getting asked to input data for the Employer field.
The first button works so i know the variable is set.
Anyone got any ideas.
Cheers
Module code:
Option Compare Database
Global CurrentCompany As String
Option Explicit
Public Sub Set_A()
CurrentCompany = "[Employer] IN (Company A Ltd')"
End Sub
Public Sub Set_BC()
CurrentCompany = "[Employer] IN ('Comapny B Ltd', 'Company C Ltd')"
End Sub
............................................................................................................
1st Form command button:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
DoCmd.Close
Call Set_A
Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = CurrentCompany
stDocName = "frm_Employee_Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
....................................................................................................................
2nd Form command button:
Private Sub Command105_Click()
On Error GoTo Err_Command105_Click
Dim stDocName As String
Dim stLinkCriteria As String
recnum = Me.CurrentRecord
stLinkCriteria = CurrentCompany
If Len(CurrentCompany & "") > 0 Then
stDocName = "frm_Misc_Records"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acGoTo, recnum
DoCmd.Close acForm, "frm_Employee_Form", acSaveNo
Else
MsgBox "No Company Name"
End If
Exit_Command105_Click:
Exit Sub
Err_Command105_Click:
MsgBox Err.Description
Resume Exit_Command105_Click
End Sub
.....................................................................................................