Hi.
I building a database to track and log documents. I have four combo boxes in the database. The combo boxes are used to select the information that you choose to view. The first combo box is to select the type of media (ie doc, cd, floppy, * (All), etc). The next combo box is to select the status of the document (ie active, void, *(All), etc). The third combo box is used to select the owner of the document (ie John Doe, *(All), etc). The fourth is used to select the location of the document (ie 8-9, *(All), etc). I then have a command button below that is used to open the trigger the query to open the report based on this criteria. I seem to be having trouble with my status combo box. It will only trigger active reports. When I select void it will open a blank report. What do I need to do.
Here is the row source for my status combo box:
SELECT DISTINCT [DOCUMENTS LOG].[STATUS] FROM [DOCUMENTS LOG] Union SELECT "*" FROM [DOCUMENTS LOG]
I have this placed in the criteria line of my query:
Like [Forms]![Select Document]![Combo98]
Here is the code for my command button:
Private Sub Command100_Click()
Dim strWhere As String
Dim strSQL As String
If IsNull(Me.Combo96) Then
strSQL = strSQL & vbNullString
Else
strSQL = strSQL & " And TYPE = " & Me!Combo96 & "'"
End If
If IsNull(Me.Combo98) Then
strSQL = strSQL & vbNullString
Else
strSQL = strSQL & " And STATUS = " & Me!Combo98 & "'"
End If
If strSQL <> vbNullString Then
strSQL = Mid(strSQL, 6) & ";"
End If
If IsNull(Me.Combo109) Then
strSQL = strSQL & vbNullString
Else
strSQL = strSQL & " And [OWNER] = " & Me!Combo109 & "'"
End If
If strSQL <> vbNullString Then
strSQL = Mid(strSQL, 6) & ";"
End If
If IsNull(Me.Combo113) Then
strSQL = strSQL & vbNullString
Else
strSQL = strSQL & " And [LOCATION] = " & Me!Combo113 & "'"
End If
If strSQL <> vbNullString Then
strSQL = Mid(strSQL, 6) & ";"
End If
strWhere = "SELECT * FROM [Select] WHERE" & strSQL
DoCmd.OpenReport "Select", acViewPreview, strSQL
End Sub
After doing a little bit more research I changed the Command100 button code to.
Private Sub Command100_Click()
Dim db As DAO.Database
Dim QD As QueryDef
Dim where As Variant
Set db = CurrentDb()
On Error Resume Next
db.querydefs.Delete ("Status"
On Error GoTo 0
where = Null
where = where & " AND [TYPE] '" + Me![Combo96] + "'"
where = where & " AND [STATUS] '" + Me![Combo98] + "'"
where = where & " AND [OWNER] '" + Me![Combo109] + "'"
where = where & " AND [LOCATION] '" + Me![Combo113] + "'"
strWhere = "SELECT * FROM [Select] WHERE" & strSQL
DoCmd.OpenReport "Select", acViewPreview, strSQL
End Sub
I am not sure if I need to add more to it or if what to do next.
Please help me if you can. Thank you very much in advance. I really appreciate all of the help.
Thanks,
Jon
I building a database to track and log documents. I have four combo boxes in the database. The combo boxes are used to select the information that you choose to view. The first combo box is to select the type of media (ie doc, cd, floppy, * (All), etc). The next combo box is to select the status of the document (ie active, void, *(All), etc). The third combo box is used to select the owner of the document (ie John Doe, *(All), etc). The fourth is used to select the location of the document (ie 8-9, *(All), etc). I then have a command button below that is used to open the trigger the query to open the report based on this criteria. I seem to be having trouble with my status combo box. It will only trigger active reports. When I select void it will open a blank report. What do I need to do.
Here is the row source for my status combo box:
SELECT DISTINCT [DOCUMENTS LOG].[STATUS] FROM [DOCUMENTS LOG] Union SELECT "*" FROM [DOCUMENTS LOG]
I have this placed in the criteria line of my query:
Like [Forms]![Select Document]![Combo98]
Here is the code for my command button:
Private Sub Command100_Click()
Dim strWhere As String
Dim strSQL As String
If IsNull(Me.Combo96) Then
strSQL = strSQL & vbNullString
Else
strSQL = strSQL & " And TYPE = " & Me!Combo96 & "'"
End If
If IsNull(Me.Combo98) Then
strSQL = strSQL & vbNullString
Else
strSQL = strSQL & " And STATUS = " & Me!Combo98 & "'"
End If
If strSQL <> vbNullString Then
strSQL = Mid(strSQL, 6) & ";"
End If
If IsNull(Me.Combo109) Then
strSQL = strSQL & vbNullString
Else
strSQL = strSQL & " And [OWNER] = " & Me!Combo109 & "'"
End If
If strSQL <> vbNullString Then
strSQL = Mid(strSQL, 6) & ";"
End If
If IsNull(Me.Combo113) Then
strSQL = strSQL & vbNullString
Else
strSQL = strSQL & " And [LOCATION] = " & Me!Combo113 & "'"
End If
If strSQL <> vbNullString Then
strSQL = Mid(strSQL, 6) & ";"
End If
strWhere = "SELECT * FROM [Select] WHERE" & strSQL
DoCmd.OpenReport "Select", acViewPreview, strSQL
End Sub
After doing a little bit more research I changed the Command100 button code to.
Private Sub Command100_Click()
Dim db As DAO.Database
Dim QD As QueryDef
Dim where As Variant
Set db = CurrentDb()
On Error Resume Next
db.querydefs.Delete ("Status"
On Error GoTo 0
where = Null
where = where & " AND [TYPE] '" + Me![Combo96] + "'"
where = where & " AND [STATUS] '" + Me![Combo98] + "'"
where = where & " AND [OWNER] '" + Me![Combo109] + "'"
where = where & " AND [LOCATION] '" + Me![Combo113] + "'"
strWhere = "SELECT * FROM [Select] WHERE" & strSQL
DoCmd.OpenReport "Select", acViewPreview, strSQL
End Sub
I am not sure if I need to add more to it or if what to do next.
Please help me if you can. Thank you very much in advance. I really appreciate all of the help.
Thanks,
Jon