The Archn00b
Registered User.
- Local time
- Yesterday, 18:07
- Joined
- Jun 26, 2013
- Messages
- 76
I've attempted to create a form with a dynamic subform. Records for the subform are filtered using check boxes which supplies parameters to the Visual Basic script (below). The VB Script changes the Record Source (SQL) of the subform.
Checkbox variables are defined/declared:
Then the SQL for the Record Source is created:
Private Sub Submit_Button_Click()
Access asks me to input values for Parameters 1 and 2. I type in the values that I want and the code, works fine. However the problem is it is not finding values for Parameters 1 and 2.
Any ideas?
Thanks for reading!
:banghead:
Checkbox variables are defined/declared:
Code:
Private Sub Check1_Click()
Dim Check1Value As Boolean
Check1Value = Check1.Value
End Sub
Private Sub Check2_Click()
Dim Check2Value As Boolean
Check2Value = Check2.Value
End Sub
Then the SQL for the Record Source is created:
Private Sub Submit_Button_Click()
Code:
Dim Parameter1 As String
If Check1Value = "True" Then
Parameter1 = "Member_types = 1"
Else
Parameter1 = ""
End If
Dim Parameter2 As String
If Check2Value = "True" Then
If Check2Value = "" Then
Parameter2 = "Member_types = 2"
Else
Parameter2 = "OR Member_types = 2"
End If
Else
Parameter2 = ""
End If
Dim Record_Source As String
Record_Source = "SELECT * FROM Query WHERE Check1Value & Check2Value"
Forms!Form!Subform.Form.RecordSource = Record_Source
End Sub
Access asks me to input values for Parameters 1 and 2. I type in the values that I want and the code, works fine. However the problem is it is not finding values for Parameters 1 and 2.
Any ideas?
Thanks for reading!
:banghead:
Last edited: