PC Review


Reply
Thread Tools Rate Thread

Display records selected by user in a combo box

 
 
Chad_jsu@yahoo.com
Guest
Posts: n/a
 
      6th Nov 2006
I have a simple database with one table. The table will be used to
enter data for multiple users on a weekly basis. One feature that I
want is to have a form with a combo box populated with all of the users
(which is a field in the table) that, when selected, will display all
of the records for that user on the form. I have tried several
different ways of doing this with minimal success. Can anyone tell me
how to do this correctly? Thanks.

 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      6th Nov 2006
On 6 Nov 2006 13:59:46 -0800, (E-Mail Removed) wrote:

>I have a simple database with one table. The table will be used to
>enter data for multiple users on a weekly basis. One feature that I
>want is to have a form with a combo box populated with all of the users
>(which is a field in the table) that, when selected, will display all
>of the records for that user on the form. I have tried several
>different ways of doing this with minimal success. Can anyone tell me
>how to do this correctly? Thanks.


Sounds like you really need some more tables! You should, at the very
least, have a table of Users (which you can populate using a SELECT
DISTINCT append query from your current table).

WHat you can do with the current design is to set the Form's Filter
property in the AfterUpdate event of a combo box. The combo should be
based on a Query like

SELECT DISTINCT UserID, Username
FROM yourtable
ORDER BY Username;

(adjusted of course to your table structure); in the combo's
AfterUpdate event use

Me.Filter = "[UserID] = " & Me.cboSelectUser

or

Me.Filter = "[Username] = '" & Me.cboSelectUser & "'"

depending on whether the user field is number or text, respectively.

John W. Vinson[MVP]
 
Reply With Quote
 
Chad_jsu@yahoo.com
Guest
Posts: n/a
 
      9th Nov 2006
When I put Me.Filter = "[Username] = '" & Me.cboSelectUser & "'" into
the AfterUpdate field I get an error saying that the Macro 'Me' can not
be found.


John Vinson wrote:
> On 6 Nov 2006 13:59:46 -0800, (E-Mail Removed) wrote:
>
> >I have a simple database with one table. The table will be used to
> >enter data for multiple users on a weekly basis. One feature that I
> >want is to have a form with a combo box populated with all of the users
> >(which is a field in the table) that, when selected, will display all
> >of the records for that user on the form. I have tried several
> >different ways of doing this with minimal success. Can anyone tell me
> >how to do this correctly? Thanks.

>
> Sounds like you really need some more tables! You should, at the very
> least, have a table of Users (which you can populate using a SELECT
> DISTINCT append query from your current table).
>
> WHat you can do with the current design is to set the Form's Filter
> property in the AfterUpdate event of a combo box. The combo should be
> based on a Query like
>
> SELECT DISTINCT UserID, Username
> FROM yourtable
> ORDER BY Username;
>
> (adjusted of course to your table structure); in the combo's
> AfterUpdate event use
>
> Me.Filter = "[UserID] = " & Me.cboSelectUser
>
> or
>
> Me.Filter = "[Username] = '" & Me.cboSelectUser & "'"
>
> depending on whether the user field is number or text, respectively.
>
> John W. Vinson[MVP]


 
Reply With Quote
 
student huang
Guest
Posts: n/a
 
      9th Nov 2006

<(E-Mail Removed)>
??????:(E-Mail Removed)...
> When I put Me.Filter = "[Username] = '" & Me.cboSelectUser & "'" into
> the AfterUpdate field I get an error saying that the Macro 'Me' can not
> be found.
>
>
> John Vinson wrote:
>> On 6 Nov 2006 13:59:46 -0800, (E-Mail Removed) wrote:
>>
>> >I have a simple database with one table. The table will be used to
>> >enter data for multiple users on a weekly basis. One feature that I
>> >want is to have a form with a combo box populated with all of the users
>> >(which is a field in the table) that, when selected, will display all
>> >of the records for that user on the form. I have tried several
>> >different ways of doing this with minimal success. Can anyone tell me
>> >how to do this correctly? Thanks.

>>
>> Sounds like you really need some more tables! You should, at the very
>> least, have a table of Users (which you can populate using a SELECT
>> DISTINCT append query from your current table).
>>
>> WHat you can do with the current design is to set the Form's Filter
>> property in the AfterUpdate event of a combo box. The combo should be
>> based on a Query like
>>
>> SELECT DISTINCT UserID, Username
>> FROM yourtable
>> ORDER BY Username;
>>
>> (adjusted of course to your table structure); in the combo's
>> AfterUpdate event use
>>
>> Me.Filter = "[UserID] = " & Me.cboSelectUser
>>
>> or
>>
>> Me.Filter = "[Username] = '" & Me.cboSelectUser & "'"
>>
>> depending on whether the user field is number or text, respectively.
>>
>> John W. Vinson[MVP]

>



 
Reply With Quote
 
John Vinson
Guest
Posts: n/a
 
      9th Nov 2006
On 8 Nov 2006 20:51:23 -0800, (E-Mail Removed) wrote:

>When I put Me.Filter = "[Username] = '" & Me.cboSelectUser & "'" into
>the AfterUpdate field I get an error saying that the Macro 'Me' can not
>be found.
>


sorry... should have clarified!

Don't put the VBA code in the property itself. Instead, clear the
property; click the ... icon; select Code Builder, and put that line
(changing the field and control names to match those in your database,
which I of course do not know!) between the Sub and End Sub lines that
Access will give you.

John W. Vinson[MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
combo box selected records reneets1 Microsoft Access Queries 1 11th Sep 2009 08:46 PM
Item selected in combo box afftects all records =?Utf-8?B?Y2hlbGxl?= Microsoft Access Forms 3 19th Nov 2004 08:36 PM
Restrict records after combo selected an Microsoft Access Forms 0 18th Aug 2004 02:03 PM
Print selected records from combo Where Date =?Utf-8?B?ZGQ=?= Microsoft Access Form Coding 1 18th Apr 2004 02:12 AM
Print Selected records by combo box =?Utf-8?B?REQ=?= Microsoft Access Form Coding 2 18th Apr 2004 01:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:13 PM.