G
Guest
How do I filter data in a form by date? I have a combobox that contains
all the dates that are registered so far. I want to use the combobox to
filter the form by the date I choose.
Here's a copy of the code I have used on other similar filters not
containing dates:
Private Sub Kombinasjonsboks45_AfterUpdate()
On Error GoTo Err_Kombinasjonsboks45_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "skjInnrykksregistrering"
stLinkCriteria = "[Tropp]=" & "'" & Kombinasjonsboks45.Text & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Kombinasjonsboks45_Click:
Exit Sub
Err_Kombinasjonsboks45_Click:
MsgBox Err.Description
Resume Exit_Kombinasjonsboks45_Click
End Sub
I tried to do this with the combobox containing dates, but it doesn't work.
Here's what I tried:
Private Sub Kombinasjonsboks75_AfterUpdate()
On Error GoTo Err_Kombinasjonsboks75_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "skjInnrykksregistrering"
stLinkCriteria = "[UT DATO]=" & "'" & Kombinasjonsboks75.Text & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Kombinasjonsboks75_Click:
Exit Sub
Err_Kombinasjonsboks75_Click:
MsgBox Err.Description
Resume Exit_Kombinasjonsboks75_Click
End Sub
all the dates that are registered so far. I want to use the combobox to
filter the form by the date I choose.
Here's a copy of the code I have used on other similar filters not
containing dates:
Private Sub Kombinasjonsboks45_AfterUpdate()
On Error GoTo Err_Kombinasjonsboks45_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "skjInnrykksregistrering"
stLinkCriteria = "[Tropp]=" & "'" & Kombinasjonsboks45.Text & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Kombinasjonsboks45_Click:
Exit Sub
Err_Kombinasjonsboks45_Click:
MsgBox Err.Description
Resume Exit_Kombinasjonsboks45_Click
End Sub
I tried to do this with the combobox containing dates, but it doesn't work.
Here's what I tried:
Private Sub Kombinasjonsboks75_AfterUpdate()
On Error GoTo Err_Kombinasjonsboks75_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "skjInnrykksregistrering"
stLinkCriteria = "[UT DATO]=" & "'" & Kombinasjonsboks75.Text & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Kombinasjonsboks75_Click:
Exit Sub
Err_Kombinasjonsboks75_Click:
MsgBox Err.Description
Resume Exit_Kombinasjonsboks75_Click
End Sub