I have a form connected to a table called floods. On this form I want to filter the records by date, municipality, and drainageway.the date comes from the floods table but the municipality and the drainageway are both subforms connected to the tables municipalities and drainageways respectively.I have tried to come up with the codes for these filters but nothings is working right.part of my code is below. Any help with this would be greatly appreciated. Thanks!
I made a text box for the filter date named Find Date and 2 combo boxes for the municipality and drainageway maned Find Minucip and Find Dway.
I made a text box for the filter date named Find Date and 2 combo boxes for the municipality and drainageway maned Find Minucip and Find Dway.
Code:
Private Sub FindDway_AfterUpdate() Dim strSQL As String If IsNull(Me.FindDway) Then ' If the combo is Null, use the whole table as the RecordSource. Me.RecordSource = "floods" Else strSQL = "SELECT DISTINCTROW floods.* FROM floods " & _ "INNER JOIN drainageways ON " & _ "floods.floodid = drainageways.dwayid " & _ "WHERE drainageways.dwayid = " & Me.FindDway & ";" Me.RecordSource = strSQL End If End Sub Private Sub FindMunicip_AfterUpdate() Dim strSQL As String If IsNull(Me.FindMunicip) Then ' If the combo is Null, use the whole table as the RecordSource. Me.RecordSource = "floods" Else strSQL = "SELECT DISTINCTROW floods.* FROM floods " & _ "INNER JOIN municipalities ON " & _ "floods.floodid = municipalities.municipid " & _ "WHERE municipalities.municipid = " & Me.FindMunicip & ";" Me.RecordSource = strSQL End If End Sub
Comment