borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (VBA in Visio)Next Topic (find a Suite.) New Topic New Poll Post Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : Requery listbox
Poster Message
MikeTL
Level: Trainee

Registered: 26-10-2005
Posts: 1

icon Requery listbox

Here is the problem:

I have a form with a listbox on the left containing a list of user names.  If you click a name in the listbox it updates the fields on the right displaying names etc. so far so good.

I have a cmd button labled "add user" (new record function).  If you click that and enter all of the info it doesn’t automatically update the list box showing the new record.  So I created an experimental button to test code.  What I am trying to do is get it to update the list box.  I have tried stuff like lbxUserList.SetFocus and an ongotfocus for the listbox such as DoCmd.Requery "lbxUserList".  If I click on the listbox the requery works great but the lbxUserList.SetFocus doesn’t seem to trigger it…….

Any help would be greatly appreciatied!

P.S.  I am very new to Access and VB, simple is good!

Thanks in advance.

26-10-2005 at 07:27 PM
View Profile Send Email to User Show All Posts | Quote Reply
TJ_01
Level: VB Lord


Registered: 24-08-2005
Posts: 320
icon Re: Requery listbox

Hi MikeTL.
Welcome to andreavb.com

quote:
If you click that and enter all of the info it doesn’t automatically update the list box showing the new record

Try this one:


Private Sub cmdSave_Click()
'Code here that save records
Call UpdateList
End Sub

This will load the records in the listbox again after saving the record

Private Sub UpdateList()
While Not rs.EOF
List1.AddItem rs.Fields("name")
rs.MoveNext
Wend
rs.Close
Set rs = NothingEnd Sub


NOTE: AIR CODED

HTH.

____________________________
Im JAMES  
27-10-2005 at 03:00 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : Requery listbox
Previous Topic (VBA in Visio)Next Topic (find a Suite.) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder