A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Update the subform or refresh based on multiple selection in a lis



 
 
Thread Tools Display Modes
  #1  
Old July 16th, 2009, 09:52 PM posted to microsoft.public.access.forms
Kris
external usenet poster
 
Posts: 220
Default Update the subform or refresh based on multiple selection in a lis

I have a list box with multiple seletion set to "simple".Based on the
selection made i build the query using the following code

Function s()

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Forms![ROC-Home1]
Set ctl = frm![control-list]

strSQL = "SELECT Table3.* FROM Table3 WHERE [Controls]="

For Each varItem In ctl.ItemsSelected
If ctl.ItemData(varItem) = "(All)" Then 'added
strSQL = "SELECT Table3.* FROM Table3 OR [Controls]=" 'added
Exit For
End If
strSQL = strSQL & "'" & ctl.ItemData(varItem) & "'" & " OR [Controls]="
Next varItem

'Trim the end of strSQL
strSQL = Left(strSQL, Len(strSQL) - Len(" OR [Controls]="))
strSQL = strSQL & ";"
CurrentDb.QueryDefs("Query3").SQL = strSQL
DoCmd.Requery ""
End Function

The query is built fine and is correct.
I have a subform to which the source-object is query3.
When i change the seletion in the listbox and run the code(with the help of
a macro)
the subform data doesnt change even though the query has been changed.
I can see the changes when i close the form and reopen it.
I need a way to sync the subform with changes done in the listbox and
running the function s().
  #2  
Old July 16th, 2009, 10:08 PM posted to microsoft.public.access.forms
Kris
external usenet poster
 
Posts: 220
Default Update the subform or refresh based on multiple selection in a lis

The list box is an unbound listbox.
I tried this statement for requery
Forms![ROC-Home1]![Query3 subform].Form.Requery but it dint work.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:21 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.