Refresh a Control

G

Guest

I need to refresh a listbox without refreshing anything else on the form.

I have multiple list boxes(listX) that may already be selected but I have
one list box (list2)that limits the next list box(list3) depending on what is
selected in it.

If I use me.refresh to update the list3 it works but the problem is it
refreshes listX also which I cannot have.

Each list box sets criteria for a query so I need them to stay.

I have tried requiry but this does nothing.

How can I refresh a control not the whole form?

I have tried requery but this does not work - nor does repaint.

I have tried docmd.ref
 
G

Guest

Set the Row Source of the second list box to a query where the criteria equals

Something like this

Forms![Form1]![List1]
 
G

Graham R Seach

Dave,

Me!cboMyCombo.Requery

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
G

Guest

No luck. If I close and re-open my form it shows the correct data - I need
'instant' updates.

I can do the requery for combo boxes etc in other parts of the form but not
this part. The difference is that when I click on list box 1 it actually
creates a query that the listbox 2 is based on. Therefore everytime I 'on
click' on list 1 it makes a new query which is based on a multi-select list
box using an 'in' sql where option.

on click Code for list box 1 :
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String

Set db = CurrentDb

strSQL = "SELECT tblproductline.* FROM tblproductline WHERE "
strSQL = strSQL & "[groupID] In (" & Me![GroupSelected] & ")"

db.QueryDefs.Delete "qryProductLinelist"
Set qdf = db.CreateQueryDef("qryProductLineList", strSQL)

'This creates a query based on the multi-select list box Grouplist
(there is another module that creates 'GroupSelected')

'refresh command required here I believe for the productlinelist which is
based on the choice in the grouplist.

Thats why I need a 'refresh' not a 'requery'. I think that a refresh is
required to update the underlying records but my problem is that 'refresh'
seems to be based on a form - not a list box based on a different query

If I do a me.refresh it takes away my other selections I have made in other
list boxes in my form - I have approx 5 of them.
Confused?

I am willing to post the .mdb if necessary

Thanks
 
G

Graham R Seach

Dave,

I don't see how using Requery can't work.

You also said "...in other parts of the form but not this part". What parts
are you talking about?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 

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

Similar Threads

Refresh a form 1
Listbox Requery 6
Refresh Combo Box - Unbound Form 2
Listbox Updating 2
Form Refresh 1
refresh list box 1
Requery not working 8
List box - doesn't refresh 1

Top