Listbox to Text boxes

xp1

New member
Local time
Today, 09:34
Joined
Nov 8, 2007
Messages
6
Hey,

Sorry if this topic was already posted before, I wanted to know how to view/edit records using the text boxes that should be linked to a list box; so when a record is selected in the list box, it would be displayed in the two text boxes. I already have all my buttons working, and list box populated with data. What I really want to do is the proper "Record Navigation" via List Box.

Thanks,
 

Attachments

  • DBsample.jpg
    DBsample.jpg
    24.8 KB · Views: 113
option 1:
- your form is based on a table and the ID-field is on the form (it can be hidden)
- your listbox is based on the same table and the ID-field is in the first column (0) (it can be hidden).
Code:
sub listbox_click (or afterupdate)
    me.recordset.findfirst "YourIDField = " & me.yourlistbox
end sub

option 2:
- your form is based on a query of the table and includes criteria in the ID-field (forms!yourform!yourlistbox)
- your listbox is same as option 1
Code:
sub listbox_click (or afterupdate)
    me.requery
end sub
 
Thank you very much, the first option worked for me just fine.
Don't want to bother you too much, my next question would be how do I get the right record count from the list box? When I select a record I would like to have a text box to show me eg. "This is 2 of 10" record.

Thanks.
 
Never mind, I got it!

Thanks for your help with the previous code, it is much appreciated :)


Private Sub Form_Current()

Me.txtCount = Me.CurrentRecord & " of " & Me.RecordsetClone.RecordCount

End Sub
 

Users who are viewing this thread

Back
Top Bottom