Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
Private Sub chkAllActiviteiten_AfterUpdate()
If Me.chkAllActiviteiten.Value = -1 Then
For x = 0 To Me.lstActiviteiten.ListCount - 1
Me.lstActiviteiten.Selected(x) = True
Next x
Else
For x = 0 To Me.lstActiviteiten.ListCount - 1
Me.lstActiviteiten.Selected(x) = False
Next x
End If
End Sub
Private Sub openquery_Click()
On Error GoTo Err_openQuery_Click
Dim MyDB As DAO.Database
Dim qdef As DAO.QueryDef
Dim i As Integer
Dim strSQL As String
Dim strWhere As String
Dim strWhere1 As String
Dim strWhere2 As String
Dim strWhere3 As String
Dim strIN As String
Dim flgSelectAll As Boolean
Dim varItem As Variant
Set MyDB = CurrentDb()
strSQL = "SELECT * FROM table2"
'Build the IN string by looping through the first listbox
For Each varItem In lstactiviteiten.ItemsSelected
If lstactiviteiten.Column(0, varItem) = " All" Then
flgSelectAll = True
Exit For
End If
strIN = strIN & "'" & lstactiviteiten.Column(0, varItem) & "',"
Next varItem
'Create the WHERE string, and strip off the last comma of the IN string
' If "All" was selected, don't create the WHERE string
If flgSelectAll1 = False Then
strWhere1 = " [activiteiten] IN (" & Left(strIN, Len(strIN) - 1) & ")"
Else
strWhere1 = ""
End If
strIN = ""
flgSelectAll = False
'Build the IN string by looping through the second listbox
For Each varItem In lstweeknr.ItemsSelected
If lstweeknr.Column(0, varItem) = " All" Then
flgSelectAll = True
Exit For
End If
strIN = strIN & "'" & lstweeknr.Column(0, varItem) & "',"
Next varItem
'Create the WHERE string, and strip off the last comma of the IN string
' If "All" was selected, don't create the WHERE string
If flgSelectAll = False Then
strWhere2 = " WHERE [weeknr_ID] IN (" & Left(strIN, Len(strIN) - 1) & ")"
Else
strWhere2 = ""
End If
strIN = ""
flgSelectAll = False
'Build the IN string by looping through the third listbox
For Each varItem In lstjaar.ItemsSelected
If lstjaar.Column(0, varItem) = " All" Then
flgSelectAll = True
Exit For
End If
strIN = strIN & "'" & lstjaar.Column(0, varItem) & "',"
Next varItem
'Create the WHERE string, and strip off the last comma of the IN string
' If "All" was selected, don't create the WHERE string
If flgSelectAll = False Then
strWhere3 = " WHERE [jaar_ID] IN (" & Left(strIN, Len(strIN) - 1) & ")"
Else
strWhere3 = ""
End If
' Build the overall WHERE clause
If Len(strWhere1) > 0 Then
strWhere = strWhere1
End If
If Len(strWhere2) > 0 Then
If Len(strWhere) > 0 Then
strWhere = strWhere & " AND " & strWhere2
Else
strWhere = strWhere2
End If
End If
If Len(strWhere3) > 0 Then
If Len(strWhere) > 0 Then
strWhere = strWhere & " AND " & strWhere3
Else
strWhere = strWhere3
End If
End If
If Len(strWhere) > 0 Then
strSQL = strSQL & " WHERE " & strWhere
End If
MyDB.QueryDefs.Delete " qrymultiselect "
Set qdef = MyDB.CreateQueryDef("qrymultiselect", strSQL)
'Open the query, built using the IN clause to set the criteria
DoCmd.openquery " qryselectie ", acViewNormal
'Clear listbox selection after running query
For Each varItem In Me.lstactiviteiten.ItemsSelected
Me.lstactiviteiten.Selected(varItem) = False
Next varItem
Exit_openQuery_Click:
Exit Sub
Err_openQuery_Click:
If Err.Number = 5 Then
MsgBox "Please make a selection from each list", , "Selection Required !"
Resume Exit_openQuery_Click
Else
'Write out the error and exit the sub
MsgBox Err.Description
Resume Exit_openQuery_Click
End If
End Sub
Private Sub OpenQuery_Click()
On Error GoTo Err_openQuery_Click
Dim MyDB As DAO.Database
Dim qdef As DAO.QueryDef
Dim i As Integer
Dim strSQL As String
Dim strWhere As String, strWhere1 As String, strWhere2 As String, strWhere3 As String
Dim strIN As String
Dim flgSelectAll As Boolean, bSelect1 As Boolean, bSelect2 As Boolean, bSelect3 As Boolean
Dim varItem As Variant
Set MyDB = CurrentDb()
strSQL = "SELECT * FROM table2 "
'Build the IN string by looping through the first listbox
For Each varItem In lstactiviteiten.ItemsSelected
If lstactiviteiten.Column(0, varItem) = " All" Then
flgSelectAll = True
Exit For
End If
If IsNumeric(lstactiviteiten.Column(0, varItem)) Then
strIN = strIN & lstactiviteiten.Column(0, varItem) & ","
Else
strIN = strIN & "'" & lstactiviteiten.Column(0, varItem) & "',"
End If
bSelect1 = True
Next varItem
'Create the WHERE string, and strip off the last comma of the IN string
' If "All" was selected, don't create the WHERE string
If flgSelectAll = False Then
strWhere1 = " [activiteiten] IN (" & Left(strIN, Len(strIN) - 1) & ")"
Else
strWhere1 = ""
End If
strIN = ""
flgSelectAll = False
'Build the IN string by looping through the second listbox
For Each varItem In lstweeknr.ItemsSelected
If lstweeknr.Column(0, varItem) = " All" Then
flgSelectAll = True
Exit For
End If
If IsNumeric(lstweeknr.Column(0, varItem)) Then
strIN = strIN & lstweeknr.Column(0, varItem) & ","
Else
strIN = strIN & "'" & lstweeknr.Column(0, varItem) & "',"
End If
bSelect2 = True
Next varItem
'Create the WHERE string, and strip off the last comma of the IN string
' If "All" was selected, don't create the WHERE string
If flgSelectAll = False Then
strWhere2 = " [weeknr_ID] IN (" & Left(strIN, Len(strIN) - 1) & ")"
Else
strWhere2 = ""
End If
strIN = ""
flgSelectAll = False
'Build the IN string by looping through the third listbox
For Each varItem In lstJaar.ItemsSelected
If lstJaar.Column(0, varItem) = " All" Then
flgSelectAll = True
Exit For
End If
If IsNumeric(lstJaar.Column(0, varItem)) Then
strIN = strIN & lstJaar.Column(0, varItem) & ","
Else
strIN = strIN & "'" & lstJaar.Column(0, varItem) & "',"
End If
bSelect3 = True
Next varItem
'Create the WHERE string, and strip off the last comma of the IN string
' If "All" was selected, don't create the WHERE string
If flgSelectAll = False Then
strWhere3 = " [jaar_ID] IN (" & Left(strIN, Len(strIN) - 1) & ")"
Else
strWhere3 = ""
End If
' Build the overall WHERE clause
If Len(strWhere1) > 0 Then strWhere = strWhere1
If Len(strWhere2) > 0 Then
If Len(strWhere) > 0 Then
strWhere = strWhere & " AND " & strWhere2
Else
strWhere = strWhere2
End If
End If
If Len(strWhere3) > 0 Then
If Len(strWhere) > 0 Then
strWhere = strWhere & " AND " & strWhere3
Else
strWhere = strWhere3
End If
End If
If Len(strWhere) > 0 Then
strSQL = strSQL & " WHERE " & strWhere
End If
''Dim tmp
''tmp = InputBox("", "", strSQL)
On Error Resume Next
MyDB.QueryDefs.Delete "qryMultiselect"
Set qdef = MyDB.CreateQueryDef("qryMultiselect", strSQL)
'Open the query, built using the IN clause to set the criteria
DoCmd.openquery "qryMultiselect", acViewNormal
'Clear listbox selection after running query
For Each varItem In Me.lstactiviteiten.ItemsSelected
Me.lstactiviteiten.Selected(varItem) = False
Next varItem
Exit_openQuery_Click:
Exit Sub
Err_openQuery_Click:
If Err.Number = 5 Then
MsgBox "Please make a selection from each list", , "Selection Required !"
Resume Exit_openQuery_Click
Else
'Write out the error and exit the sub
MsgBox Err.Description
Resume Exit_openQuery_Click
End If
End Sub
SELECT DISTINCT "All"
FROM Table2
UNION ALL
SELECT DISTINCT Weeknr_ID
FROM Table2
WHERE (Weeknr_ID Is Not Null)
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.