Help with this Search button

F

forest8

Hi

I have a database of students.

I have created a search box (through an unbound box).

I have the following in the rowsource:

Row Source: SELECT DISTINCT [First Name] FROM T_Participants ORDER BY [First
Name];
Row Source Type: Table/Query
Bound Column: 1
Lmit to List: Yes
Allow Value List Edit: No
Inherit Value List: Yes
Show Only Row Source: No

While a list of names does appear in the search box, the form below the
search button does not change.

What do I do to fix this button so that it gives me the desired form?

Thank you in advance for your help.
 
J

John W. Vinson

Hi

I have a database of students.

I have created a search box (through an unbound box).

I have the following in the rowsource:

Row Source: SELECT DISTINCT [First Name] FROM T_Participants ORDER BY [First
Name];
Row Source Type: Table/Query
Bound Column: 1
Lmit to List: Yes
Allow Value List Edit: No
Inherit Value List: Yes
Show Only Row Source: No

While a list of names does appear in the search box, the form below the
search button does not change.

What do I do to fix this button so that it gives me the desired form?

Thank you in advance for your help.

Well, there is absolutely nothing in your combo box that would do anything
about searching or changing the contents of a form.

As it is, your combo box would have some real problems. Suppose you had four
students named Bill, Bill, Bill and Bill. Which of them would you want to see
in the form if you select Bill from this combo!? The SELECT DISTINCT will make
all four students appear on the same row (as an uninformative "Bill") in your
combo.

Normally you would have a rowsource such as

SELECT [StudentID], [FirstName], [LastName] FROM T_Participants ORDER BY
[FirstName], [LastName];

with a bound column 1, ColumnCOunt 3, ColumnWidths 0";1";1" in order to see

Aaron Moskowitz
Arlene Brown
Bill Johnson
Bill Smith
Bill Torrance
Bill Wilson

and so on; then there would be VBA code in the combo box's AfterUpdate event
to actually navigate to Bill Torrance's or whichever record was selected. The
Combo Box Wizard has an option "Use this combo to find a record" that will
write the code for you.
 
F

forest8

Hi there

I made tje suggested change and I now see both the first name and last name
in the search.

But I have two questions:

1. The names aren't alphabetically. Is it possible to have the names sorted
by their first name?

2. I'm not very good with code. So how should I write the AfterUpdate Event
procedure so that it actually goes to the correct record?

Thank you in advance for your help.

John W. Vinson said:
Hi

I have a database of students.

I have created a search box (through an unbound box).

I have the following in the rowsource:

Row Source: SELECT DISTINCT [First Name] FROM T_Participants ORDER BY [First
Name];
Row Source Type: Table/Query
Bound Column: 1
Lmit to List: Yes
Allow Value List Edit: No
Inherit Value List: Yes
Show Only Row Source: No

While a list of names does appear in the search box, the form below the
search button does not change.

What do I do to fix this button so that it gives me the desired form?

Thank you in advance for your help.

Well, there is absolutely nothing in your combo box that would do anything
about searching or changing the contents of a form.

As it is, your combo box would have some real problems. Suppose you had four
students named Bill, Bill, Bill and Bill. Which of them would you want to see
in the form if you select Bill from this combo!? The SELECT DISTINCT will make
all four students appear on the same row (as an uninformative "Bill") in your
combo.

Normally you would have a rowsource such as

SELECT [StudentID], [FirstName], [LastName] FROM T_Participants ORDER BY
[FirstName], [LastName];

with a bound column 1, ColumnCOunt 3, ColumnWidths 0";1";1" in order to see

Aaron Moskowitz
Arlene Brown
Bill Johnson
Bill Smith
Bill Torrance
Bill Wilson

and so on; then there would be VBA code in the combo box's AfterUpdate event
to actually navigate to Bill Torrance's or whichever record was selected. The
Combo Box Wizard has an option "Use this combo to find a record" that will
write the code for you.
 
J

John W. Vinson

Hi there

I made tje suggested change and I now see both the first name and last name
in the search.

But I have two questions:

1. The names aren't alphabetically. Is it possible to have the names sorted
by their first name?

Follow the instructions that I posted; they will sort by first name. In the
query grid there's a row for sort order; select Ascending under firstname (and
put Lastname to the right of Firstname and sort by it too).
2. I'm not very good with code. So how should I write the AfterUpdate Event
procedure so that it actually goes to the correct record?

That is what the combo box toolbox wizard does for you without your even
needing to SEE the code. Since I don't know anything about your table names,
fieldnames, form name, control names, etc. I can't write your code for you.
 

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

Top