how can I include an asterisk in a combobox to define all?

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

Guest

In a combo box in Access 2007 (Beta), is it possible to include an asterisk
(or equivalent) to indicate "all records" as in an Excel filter dialog. I'm
fairly sure I've done this before, but can't remember how!
 
Here's a simple example of a RowSource for a combo box which does this:

SELECT AddressID, LastName,1 As SortColumn
FROM Addresses
UNION
SELECT NULL,"*",0 FROM Addresses
ORDER BY SortColumn, LastName;

The first column is hidden by setting the control's ColumnWidths property to
0cm;8cm. The ColumnCount is set to 2. How you use this depends on what you
want to happen when the user makes a selection, but here's some simple code
form the control's AfterUpdate event procedure which goes to the selected
addressee or requeries the form to go back to the first record if the user
selects *.

Private Sub cboFindName_AfterUpdate()

Dim rst As Object
Dim strCriteria As String

If Not IsNull(cboFindName) Then
strCriteria = "AddressID = " & cboFindName

Set rst = Me.Recordset.Clone
rst.FindFirst strCriteria

If Not rst.EOF Then
Me.Bookmark = rst.Bookmark
Else
MsgBox "Addressee not found"
End If
Else
Me.Requery
End If

End Sub

Ken Sheridan
Stafford, England
 
a) use SQL Server
b) use SQL Server Olap

you're already done.

-Aaron
 

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

Back
Top