Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / December 2005

Tip: Looking for answers? Try searching our database.

Select INTO ListBox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
daddydfsu - 07 Dec 2005 17:04 GMT
I am trying to create a ListBox based on a search from a TextBox.  I have a
TextBox where I will enter in a MemberAlias.  I want to click on a Search
Button and that will do a select from a PersonData Table that I have filled
out and look at each MemberAlias column for each Person on the Table.  It
will then retrieve any persons with that MemberAlias and populate it into a
ListBox, where they can then select the record from that list box and it will
open a "Chart" for that person.   I have  a ListBox now that runs off of a
SQL Statement query that has hard coded the alias that it should look for.
This pulls back the row and all of the fields and when I click on that row, I
can open the record.  How can I write the SQL behind a "Search" button that
will use the text from the TextBox and query based on that text.  Thanks in
advance for the help.
salad - 07 Dec 2005 17:25 GMT
> I am trying to create a ListBox based on a search from a TextBox.  I have a
> TextBox where I will enter in a MemberAlias.  I want to click on a Search
[quoted text clipped - 8 lines]
> will use the text from the TextBox and query based on that text.  Thanks in
> advance for the help.

Create the listbox.  In the row source (under Data tab) create the query
to list the fields in the listbox.  Let's say your form name is called
Form1.  The textbox is called MemberAlias.  The Listbox is called
Listbox1.  Under the MemberAlias field in the SQL enter
    Forms!Form1!MemberAlias

This will now filter the listbox to the alias you entered.

When you enter an alias, in the AfterUpdate event enter
    Me.ListBox1.Requery
daddydfsu - 07 Dec 2005 17:44 GMT
Okay, this looks similar to what I have.  Couple questions:

When you state, "under the MemberAlias field" how do you mean.  Is  it this:

Select *
from Person
where (MemberAlias = '[Forms]![Form1]![MemberAlias]')

Next Question:

Which Event to I place the AfterUpdate into?  The textbox, the search button.

thanks so much.

>> I am trying to create a ListBox based on a search from a TextBox.  I have a
>> TextBox where I will enter in a MemberAlias.  I want to click on a Search
[quoted text clipped - 12 lines]
>When you enter an alias, in the AfterUpdate event enter
>    Me.ListBox1.Requery
salad - 07 Dec 2005 18:23 GMT
> Okay, this looks similar to what I have.  Couple questions:
>
[quoted text clipped - 3 lines]
> from Person
> where (MemberAlias = '[Forms]![Form1]![MemberAlias]')

In the Querybuilder, on the Criteria row, enter
    [Forms]![Form1]![MemberAlias]

That's basically what you have.

> Next Question:
>
> Which Event to I place the AfterUpdate into?  The textbox, the search button.

I'm not sure why you have a Search button.  If I entered something in
the text box I'd want to update the list.  If using a button, put it in
the OnClick event.

> thanks so much.
>
[quoted text clipped - 16 lines]
>>When you enter an alias, in the AfterUpdate event enter
>>    Me.ListBox1.Requery
daddydfsu - 07 Dec 2005 18:37 GMT
It looks like I have all of this correct according to what you have posted,
it is just not pulling back the data.  I know the query works because I can
hard code the value in and it populates that listbox.  I will keep plugging
away at it.  Thanks for taking a look at this.  

>> Okay, this looks similar to what I have.  Couple questions:
>>
[quoted text clipped - 20 lines]
>>>When you enter an alias, in the AfterUpdate event enter
>>>    Me.ListBox1.Requery
David W. Fenton - 08 Dec 2005 01:02 GMT
> When you state, "under the MemberAlias field" how do you mean.  Is
>  it this:
>
> Select *
> from Person
> where (MemberAlias = '[Forms]![Form1]![MemberAlias]')

Well, you obviously have to replace "Form1" and "MemberAlias" with
the name of the form your listbox is on and the name of the unbound
control that you are typing the alias into for searching.

That control is the one where the Afterupdate event should be.

Signature

David W. Fenton                        http://www.bway.net/~dfenton
dfenton at bway dot net                http://www.bway.net/~dfassoc

daddydfsu - 08 Dec 2005 02:06 GMT
Yes, I did do that and replace it with my actual names.  and I did have the
Afterupdate in the control, but it was still not working.

>> When you state, "under the MemberAlias field" how do you mean.  Is
>>  it this:
[quoted text clipped - 8 lines]
>
>That control is the one where the Afterupdate event should be.
daddydfsu - 07 Dec 2005 17:54 GMT
Also, do I put this in the Criteria Column in the SQL Query Builder.
[Forms]![Form1]![MemberAlias]

>> I am trying to create a ListBox based on a search from a TextBox.  I have a
>> TextBox where I will enter in a MemberAlias.  I want to click on a Search
[quoted text clipped - 12 lines]
>When you enter an alias, in the AfterUpdate event enter
>    Me.ListBox1.Requery
salad - 07 Dec 2005 18:24 GMT
> Also, do I put this in the Criteria Column in the SQL Query Builder.
> [Forms]![Form1]![MemberAlias]

That's what I'd do.

>>>I am trying to create a ListBox based on a search from a TextBox.  I have a
>>>TextBox where I will enter in a MemberAlias.  I want to click on a Search
[quoted text clipped - 14 lines]
>>When you enter an alias, in the AfterUpdate event enter
>>    Me.ListBox1.Requery
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.