refresh query results

K

kknoblauch

Hello all. I have a form where the user can specify the fields they would
like to query on. Then when they run the form a sub-report shows the results
in datasheet view. I have added a yes/no field to the datasheet so the user
can check on the results they want and then just those will be printed.

As the results get bigger, I would like to add a "Select All" button to the
form. This select all basically sets all the entries in issus.report to
'Yes'. However, I only want the entries from the query I just ran set to
'Yes'. No all the other ones in the table that did not meet the query.

Along the same line, I would also like an unselect all. I just don't know
how to do it for the results of the query. I have been using the following
code, but that only works for the entire table.

Dim strSql As String
strSql = "UPDATE [Issues] SET [Report] = False WHERE [Report] = True;"
DBEngine(0)(0).Execute strSql, dbFailOnError
Me.Refresh

Any help would be appreciated.
 
K

kknoblauch

Thanks for the resonse Lynn. I can re-do the query, but I can't seem to find
a way to use a select all button that will only change the Yes/No filed in
that resulted from the query. Not every one in the Table. The requery works
fine, but then I have a button that will print everything with the Yes/No set
to true. While the query show's me what I want, since every record is set to
True it prints everything.



Lynn Trapp said:
Whatever criteria is used when running the original query needs to be used
in the update query.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



kknoblauch said:
Hello all. I have a form where the user can specify the fields they would
like to query on. Then when they run the form a sub-report shows the
results
in datasheet view. I have added a yes/no field to the datasheet so the
user
can check on the results they want and then just those will be printed.

As the results get bigger, I would like to add a "Select All" button to
the
form. This select all basically sets all the entries in issus.report to
'Yes'. However, I only want the entries from the query I just ran set to
'Yes'. No all the other ones in the table that did not meet the query.

Along the same line, I would also like an unselect all. I just don't know
how to do it for the results of the query. I have been using the
following
code, but that only works for the entire table.

Dim strSql As String
strSql = "UPDATE [Issues] SET [Report] = False WHERE [Report] = True;"
DBEngine(0)(0).Execute strSql, dbFailOnError
Me.Refresh

Any help would be appreciated.
 
L

Lynn Trapp

Could you post your original query?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



kknoblauch said:
Thanks for the resonse Lynn. I can re-do the query, but I can't seem to
find
a way to use a select all button that will only change the Yes/No filed in
that resulted from the query. Not every one in the Table. The requery
works
fine, but then I have a button that will print everything with the Yes/No
set
to true. While the query show's me what I want, since every record is set
to
True it prints everything.



Lynn Trapp said:
Whatever criteria is used when running the original query needs to be
used
in the update query.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



kknoblauch said:
Hello all. I have a form where the user can specify the fields they
would
like to query on. Then when they run the form a sub-report shows the
results
in datasheet view. I have added a yes/no field to the datasheet so the
user
can check on the results they want and then just those will be printed.

As the results get bigger, I would like to add a "Select All" button to
the
form. This select all basically sets all the entries in issus.report
to
'Yes'. However, I only want the entries from the query I just ran set
to
'Yes'. No all the other ones in the table that did not meet the query.

Along the same line, I would also like an unselect all. I just don't
know
how to do it for the results of the query. I have been using the
following
code, but that only works for the entire table.

Dim strSql As String
strSql = "UPDATE [Issues] SET [Report] = False WHERE [Report] = True;"
DBEngine(0)(0).Execute strSql, dbFailOnError
Me.Refresh

Any help would be appreciated.
 
K

kknoblauch

That's kind of the rub. It is not your average query. I am filling in
unbound text boxes and that is generating the results in the sub form.

Private Sub Search_Click()
Const cInvalidDateError As String = "You have entered an invalid date."
Dim strWhere As String
Dim strError As String
strWhere = "1=1"
If Not IsNull(Me.AssignedTo) Then
strWhere = strWhere & " AND " & "Issues.[Assigned To] = " &
Me.AssignedTo & ""
End If

If Not IsNull(Me.OpenedBy) Then
strWhere = strWhere & " AND " & "Issues.[Opened By] = " &
Me.OpenedBy & ""
End If


If Nz(Me.Status) <> "" Then

strWhere = strWhere & " AND " & "Issues.Status = '" & Me.Status & "'"
End If


If Nz(Me.SubCategory) <> "" Then

strWhere = strWhere & " AND " & "Issues.Sub_Category = '" &
Me.SubCategory & "'"
End If

If Nz(Me.Type) <> "" Then

strWhere = strWhere & " AND " & "Issues.Type = '" & Me.Type & "'"
End If


If Nz(Me.Category) <> "" Then

strWhere = strWhere & " AND " & "Issues.Category = '" & Me.Category
& "'"
End If


If Nz(Me.Priority) <> "" Then

strWhere = strWhere & " AND " & "Issues.Priority = '" & Me.Priority
& "'"
End If

If IsDate(Me.OpenedDateFrom) Then

strWhere = strWhere & " AND " & "Issues.[Opened Date] >= " &
GetDateFilter(Me.OpenedDateFrom)
ElseIf Nz(Me.OpenedDateFrom) <> "" Then
strError = cInvalidDateError
End If


If IsDate(Me.OpenedDateTo) Then

strWhere = strWhere & " AND " & "Issues.[Opened Date] <= " &
GetDateFilter(Me.OpenedDateTo)
ElseIf Nz(Me.OpenedDateTo) <> "" Then
strError = cInvalidDateError
End If

If IsDate(Me.DueDateFrom) Then

strWhere = strWhere & " AND " & "Issues.[Due Date] >= " &
GetDateFilter(Me.DueDateFrom)
ElseIf Nz(Me.DueDateFrom) <> "" Then
strError = cInvalidDateError
End If


If IsDate(Me.DueDateTo) Then

strWhere = strWhere & " AND " & "Issues.[Due Date] <= " &
GetDateFilter(Me.DueDateTo)
ElseIf Nz(Me.DueDateTo) <> "" Then
strError = cInvalidDateError
End If


If Nz(Me.Title) <> "" Then

strWhere = strWhere & " AND " & "Issues.Title Like '*" & Me.Title &
"*'"
End If


If strError <> "" Then
MsgBox strError
Else

If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.Browse_All_Issues.Form.Filter = strWhere
Me.Browse_All_Issues.Form.FilterOn = True
End If

End Sub

Lynn Trapp said:
Could you post your original query?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



kknoblauch said:
Thanks for the resonse Lynn. I can re-do the query, but I can't seem to
find
a way to use a select all button that will only change the Yes/No filed in
that resulted from the query. Not every one in the Table. The requery
works
fine, but then I have a button that will print everything with the Yes/No
set
to true. While the query show's me what I want, since every record is set
to
True it prints everything.



Lynn Trapp said:
Whatever criteria is used when running the original query needs to be
used
in the update query.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



Hello all. I have a form where the user can specify the fields they
would
like to query on. Then when they run the form a sub-report shows the
results
in datasheet view. I have added a yes/no field to the datasheet so the
user
can check on the results they want and then just those will be printed.

As the results get bigger, I would like to add a "Select All" button to
the
form. This select all basically sets all the entries in issus.report
to
'Yes'. However, I only want the entries from the query I just ran set
to
'Yes'. No all the other ones in the table that did not meet the query.

Along the same line, I would also like an unselect all. I just don't
know
how to do it for the results of the query. I have been using the
following
code, but that only works for the entire table.

Dim strSql As String
strSql = "UPDATE [Issues] SET [Report] = False WHERE [Report] = True;"
DBEngine(0)(0).Execute strSql, dbFailOnError
Me.Refresh

Any help would be appreciated.
 
L

Lynn Trapp

Have you tried concatenating the variable strWhere to your update query?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



kknoblauch said:
That's kind of the rub. It is not your average query. I am filling in
unbound text boxes and that is generating the results in the sub form.

Private Sub Search_Click()
Const cInvalidDateError As String = "You have entered an invalid date."
Dim strWhere As String
Dim strError As String
strWhere = "1=1"
If Not IsNull(Me.AssignedTo) Then
strWhere = strWhere & " AND " & "Issues.[Assigned To] = " &
Me.AssignedTo & ""
End If

If Not IsNull(Me.OpenedBy) Then
strWhere = strWhere & " AND " & "Issues.[Opened By] = " &
Me.OpenedBy & ""
End If


If Nz(Me.Status) <> "" Then

strWhere = strWhere & " AND " & "Issues.Status = '" & Me.Status &
"'"
End If


If Nz(Me.SubCategory) <> "" Then

strWhere = strWhere & " AND " & "Issues.Sub_Category = '" &
Me.SubCategory & "'"
End If

If Nz(Me.Type) <> "" Then

strWhere = strWhere & " AND " & "Issues.Type = '" & Me.Type & "'"
End If


If Nz(Me.Category) <> "" Then

strWhere = strWhere & " AND " & "Issues.Category = '" & Me.Category
& "'"
End If


If Nz(Me.Priority) <> "" Then

strWhere = strWhere & " AND " & "Issues.Priority = '" & Me.Priority
& "'"
End If

If IsDate(Me.OpenedDateFrom) Then

strWhere = strWhere & " AND " & "Issues.[Opened Date] >= " &
GetDateFilter(Me.OpenedDateFrom)
ElseIf Nz(Me.OpenedDateFrom) <> "" Then
strError = cInvalidDateError
End If


If IsDate(Me.OpenedDateTo) Then

strWhere = strWhere & " AND " & "Issues.[Opened Date] <= " &
GetDateFilter(Me.OpenedDateTo)
ElseIf Nz(Me.OpenedDateTo) <> "" Then
strError = cInvalidDateError
End If

If IsDate(Me.DueDateFrom) Then

strWhere = strWhere & " AND " & "Issues.[Due Date] >= " &
GetDateFilter(Me.DueDateFrom)
ElseIf Nz(Me.DueDateFrom) <> "" Then
strError = cInvalidDateError
End If


If IsDate(Me.DueDateTo) Then

strWhere = strWhere & " AND " & "Issues.[Due Date] <= " &
GetDateFilter(Me.DueDateTo)
ElseIf Nz(Me.DueDateTo) <> "" Then
strError = cInvalidDateError
End If


If Nz(Me.Title) <> "" Then

strWhere = strWhere & " AND " & "Issues.Title Like '*" & Me.Title &
"*'"
End If


If strError <> "" Then
MsgBox strError
Else

If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.Browse_All_Issues.Form.Filter = strWhere
Me.Browse_All_Issues.Form.FilterOn = True
End If

End Sub

Lynn Trapp said:
Could you post your original query?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



kknoblauch said:
Thanks for the resonse Lynn. I can re-do the query, but I can't seem
to
find
a way to use a select all button that will only change the Yes/No filed
in
that resulted from the query. Not every one in the Table. The requery
works
fine, but then I have a button that will print everything with the
Yes/No
set
to true. While the query show's me what I want, since every record is
set
to
True it prints everything.



:

Whatever criteria is used when running the original query needs to be
used
in the update query.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



Hello all. I have a form where the user can specify the fields they
would
like to query on. Then when they run the form a sub-report shows
the
results
in datasheet view. I have added a yes/no field to the datasheet so
the
user
can check on the results they want and then just those will be
printed.

As the results get bigger, I would like to add a "Select All" button
to
the
form. This select all basically sets all the entries in
issus.report
to
'Yes'. However, I only want the entries from the query I just ran
set
to
'Yes'. No all the other ones in the table that did not meet the
query.

Along the same line, I would also like an unselect all. I just
don't
know
how to do it for the results of the query. I have been using the
following
code, but that only works for the entire table.

Dim strSql As String
strSql = "UPDATE [Issues] SET [Report] = False WHERE [Report] =
True;"
DBEngine(0)(0).Execute strSql, dbFailOnError
Me.Refresh

Any help would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top