ajaythakur
New member
- Local time
- Today, 12:46
- Joined
- Jul 20, 2016
- Messages
- 2
Hi,
I have developed a database in which I have two comboxes on a form : One "therapeutic area' and second 'phase'. Also, I have time frame(This year, This quarter,This month etc.) filter on same form. With these three filters (two comboxes and one time frame filter) I am generating a report. But, I am not to get all filtered records on my report with three filters applied on form.
Code below:
Private Sub cbotherapeuticarea_AfterUpdate()
Call SearchCriteria
End Sub
Private Sub cbophase_AfterUpdate()
Call SearchCriteria
End Sub
Function SearchCriteria()
Dim therapeuticarea, strphase As String
Dim task, strCriteria As String
If IsNull(Me.cbotherapeuticarea) Then
therapeuticarea = "[Therapeutic area] like '*'"
Else
therapeuticarea = "[Therapeutic area] = '" & Me.cbotherapeuticarea & "'"
End If
If IsNull(Me.cbophase) Then
strphase = "[Phase] like '*'"
Else
strphase = "[Phase] = '" & Me.cbophase & "'"
End If
strCriteria = therapeuticarea & "And" & strphase
task = "Select * from Biosinformation where " & strCriteria
Me.Biosinformation_subform.Form.RecordSource = task
Me.Biosinformation_subform.Form.Requery
End Function
Private Sub Command6_Click()
Me.cbotherapeuticarea = Null
Me.cbophase = Null
Me.Filter = ""
End Sub
Private Sub Command8_Click()
Dim therapeuticarea, strphase As String
Dim strCriteria As String
If IsNull(Me.cbotherapeuticarea) Then
therapeuticarea = "[Therapeutic area] like '*'"
Else
therapeuticarea = "[Therapeutic area] = '" & Me.cbotherapeuticarea & "'"
End If
If IsNull(Me.cbophase) Then
strphase = "[Phase] like '*'"
Else
strphase = "[Phase] = '" & Me.cbophase & "'"
End If
strCriteria = therapeuticarea & "And" & strphase
DoCmd.OpenReport "Biosinformation_search2", acViewPreview, , strCriteria
End Sub
Private Sub Frame15_AfterUpdate()
Dim dDate As Date
Select Case Frame15.Value
Case 1: dDate = "1/1/2016"
Case 2: dDate = "1/1/" & Year(Date)
Case 3: Select Case Month(Date)
Case 1 To 3: dDate = "1/1/" & Year(Date)
Case 4 To 6: dDate = "4/1/" & Year(Date)
Case 7 To 9: dDate = "7/1/" & Year(Date)
Case Else: dDate = "10/1/" & Year(Date)
End Select
Case 4: dDate = Month(Date) & "/1/" & Year(Date)
Case 5: dDate = Date - Weekday(Date) + 2
End Select
Me.Biosinformation_subform.Form.Filter = "[Date]>#" & dDate & "#"
Me.Biosinformation_subform.Form.FilterOn = True
If dDate = "1/1/2016" Then
Me.Biosinformation_subform.Form.FilterOn = False
End If
End Sub
If someone can help, it will be really great!
I have added attachment containing form and report.
I have developed a database in which I have two comboxes on a form : One "therapeutic area' and second 'phase'. Also, I have time frame(This year, This quarter,This month etc.) filter on same form. With these three filters (two comboxes and one time frame filter) I am generating a report. But, I am not to get all filtered records on my report with three filters applied on form.
Code below:
Private Sub cbotherapeuticarea_AfterUpdate()
Call SearchCriteria
End Sub
Private Sub cbophase_AfterUpdate()
Call SearchCriteria
End Sub
Function SearchCriteria()
Dim therapeuticarea, strphase As String
Dim task, strCriteria As String
If IsNull(Me.cbotherapeuticarea) Then
therapeuticarea = "[Therapeutic area] like '*'"
Else
therapeuticarea = "[Therapeutic area] = '" & Me.cbotherapeuticarea & "'"
End If
If IsNull(Me.cbophase) Then
strphase = "[Phase] like '*'"
Else
strphase = "[Phase] = '" & Me.cbophase & "'"
End If
strCriteria = therapeuticarea & "And" & strphase
task = "Select * from Biosinformation where " & strCriteria
Me.Biosinformation_subform.Form.RecordSource = task
Me.Biosinformation_subform.Form.Requery
End Function
Private Sub Command6_Click()
Me.cbotherapeuticarea = Null
Me.cbophase = Null
Me.Filter = ""
End Sub
Private Sub Command8_Click()
Dim therapeuticarea, strphase As String
Dim strCriteria As String
If IsNull(Me.cbotherapeuticarea) Then
therapeuticarea = "[Therapeutic area] like '*'"
Else
therapeuticarea = "[Therapeutic area] = '" & Me.cbotherapeuticarea & "'"
End If
If IsNull(Me.cbophase) Then
strphase = "[Phase] like '*'"
Else
strphase = "[Phase] = '" & Me.cbophase & "'"
End If
strCriteria = therapeuticarea & "And" & strphase
DoCmd.OpenReport "Biosinformation_search2", acViewPreview, , strCriteria
End Sub
Private Sub Frame15_AfterUpdate()
Dim dDate As Date
Select Case Frame15.Value
Case 1: dDate = "1/1/2016"
Case 2: dDate = "1/1/" & Year(Date)
Case 3: Select Case Month(Date)
Case 1 To 3: dDate = "1/1/" & Year(Date)
Case 4 To 6: dDate = "4/1/" & Year(Date)
Case 7 To 9: dDate = "7/1/" & Year(Date)
Case Else: dDate = "10/1/" & Year(Date)
End Select
Case 4: dDate = Month(Date) & "/1/" & Year(Date)
Case 5: dDate = Date - Weekday(Date) + 2
End Select
Me.Biosinformation_subform.Form.Filter = "[Date]>#" & dDate & "#"
Me.Biosinformation_subform.Form.FilterOn = True
If dDate = "1/1/2016" Then
Me.Biosinformation_subform.Form.FilterOn = False
End If
End Sub
If someone can help, it will be really great!
I have added attachment containing form and report.