List Box Rowsource = Recordset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do you set a list box's rowsource to reflect the recordset of its form,
even when the recordset it filtered?
 
Hi.
How do you set a list box's rowsource to reflect the recordset of its form,
even when the recordset it filtered?

Did the code suggested to you not work the last time you asked this question?

http://groups.google.com/group/micr...public.access.*&rnum=1&hl=en#1db0f25fa676247d

Paste the code below into your form's code module, then replace the following:

1.) ChgRowSrcBtn with the name of your button;
2.) lstList with the name of your list box.

Then save the form's code module and compile the code.

Private Sub ChgRowSrcBtn_Click()

On Error GoTo ErrHandler

If (Len(Me.Filter) > 0) Then
Me!lstList.RowSource = "SELECT * " & _
"FROM " & Me.RecordSource & _
" WHERE " & Me.Filter
Else
Me!lstList.RowSource = Me.RecordSource
End If

Me!lstList.Requery

Exit Sub

ErrHandler:

MsgBox "Error in ChgRowSrcBtn_Click( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
You're welcome.
Sorry mate, didn't get notified of a response last time.

Don't rely on getting notified by E-mail. Too many people complain of
getting other members' notifications. Microsoft's Web portal is still
buggy. If you ever wonder whether someone has responded to your question,
you can always check by doing a search on your own name:

http://www.microsoft.com/office/com...8ada&catlist=&dglist=&ptlist=&exp=&sloc=en-us

Or you can purchase a list of links to every one of your posted questions
(dating back to at least January for Access questions; April for SQL Server,
Excel, Word and Outlook questions).

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
 
Back
Top