X
xiaodan86
I have one command button used to open a form. How can I change if I
wan to open a query instead of form? I try with this but it doesn't
works. Something wrong with the code?
Or I use the wrong method?
####
strQuery = "grouping" (query name)
DoCmd.openquery strQuery, , , strSQL
####
Private Sub openform_Click()
Dim strSQL As String
Dim strWhere As String
If Not IsNull(tool_id) Then
strWhere = strWhere & " AND tool_id= " & "'" & tool_id & "'"
End If
If Not IsNull(cboStatus) Then
strWhere = strWhere & " AND status= " & "'" & cboStatus & "'"
End If
If Not IsNull(strWhere) Then
strSQL = Mid$(strWhere, 6)
End If
strForm = "history"
DoCmd.openform strForm, , , strSQL
wan to open a query instead of form? I try with this but it doesn't
works. Something wrong with the code?
Or I use the wrong method?
####
strQuery = "grouping" (query name)
DoCmd.openquery strQuery, , , strSQL
####
Private Sub openform_Click()
Dim strSQL As String
Dim strWhere As String
If Not IsNull(tool_id) Then
strWhere = strWhere & " AND tool_id= " & "'" & tool_id & "'"
End If
If Not IsNull(cboStatus) Then
strWhere = strWhere & " AND status= " & "'" & cboStatus & "'"
End If
If Not IsNull(strWhere) Then
strSQL = Mid$(strWhere, 6)
End If
strForm = "history"
DoCmd.openform strForm, , , strSQL