A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help with this Search button



 
 
Thread Tools Display Modes
  #1  
Old May 28th, 2010, 02:25 AM posted to microsoft.public.access
forest8
external usenet poster
 
Posts: 196
Default Help with this Search button

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.

  #2  
Old May 28th, 2010, 03:35 AM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Help with this Search button

On Thu, 27 May 2010 18:25:01 -0700, forest8
wrote:

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.
--

John W. Vinson [MVP]
  #3  
Old May 28th, 2010, 06:07 AM posted to microsoft.public.access
forest8
external usenet poster
 
Posts: 196
Default Help with this Search button

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" wrote:

On Thu, 27 May 2010 18:25:01 -0700, forest8
wrote:

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.
--

John W. Vinson [MVP]
.

  #4  
Old May 28th, 2010, 04:12 PM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Help with this Search button

On Thu, 27 May 2010 22:07:01 -0700, forest8
wrote:

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.
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.