A-Z Listing Form

Rockape

Registered User.
Local time
Today, 17:59
Joined
Aug 24, 2007
Messages
271
Hi all,

I don't know whether I am in the correct forum but since I am looking at creating a form I thought I might ask here.

The idea I have, simply put, is of creating an A-Z type of directory whereby by clicking on a particular letter a listing of all records commencing with the letter A will appear.

Grateful if I could be initially assisted in locating the correct forum or a sample database which I could model on.

Thanks
 
Hi,

There are lots of ways that you could achieve this. This is just one possible example.

Let's say you have a table called tblNames with a list of people's names, and you want to be able to display all the names beginning with each letter.
The field in the table in this example is called chrPersonName.

I would create a subform that displays the records how I want them to appear. I would then set the record source for the form to a query based on the main table with a calculated field called FirstLetter like this:

SQL: SELECT chrPersonName, Left(chrPersonName,1) As FirstLetter FROM tblNames WHERE Left(chrPersonName,1) = [cboFirstLetter]

Now I would create a main form with a combobox called cboFirstLetter, and set the row source to "value list", and enter the row source as "A;B;C;D;E ......." and so on.

Then add the previously created subform to the main form, and add this code to the combobox:

Code:
Sub cboFirstLetter_AfterUpdate()
    Me!SubFormNameGoesHere.Requery
End Sub
 
Thanks will retry and continue with this idea.

May get back to you via this thread.

:)





Hi,

There are lots of ways that you could achieve this. This is just one possible example.

Let's say you have a table called tblNames with a list of people's names, and you want to be able to display all the names beginning with each letter.
The field in the table in this example is called chrPersonName.

I would create a subform that displays the records how I want them to appear. I would then set the record source for the form to a query based on the main table with a calculated field called FirstLetter like this:

SQL: SELECT chrPersonName, Left(chrPersonName,1) As FirstLetter FROM tblNames WHERE Left(chrPersonName,1) = [cboFirstLetter]

Now I would create a main form with a combobox called cboFirstLetter, and set the row source to "value list", and enter the row source as "A;B;C;D;E ......." and so on.

Then add the previously created subform to the main form, and add this code to the combobox:

Code:
Sub cboFirstLetter_AfterUpdate()
    Me!SubFormNameGoesHere.Requery
End Sub
 

Users who are viewing this thread

Back
Top Bottom