Hi-
I'm creating a database of music bands with their cds and songs.
I'm trying to program an SQL statement so that I can enter a string of
text in a textbox, press the 'Enter' key, and have it return the
associated records to a listbox. Once the listbox has the records, I
want to select a record, which will open a form associated with the
selected record in the listbox.
For example:
If I enter the letter, "L," in my textbox and press the 'Enter' key,
I'd like the bands that start with the letter, "L," to appear in the
listbox, i.e. Limp Bizkit, Led Zeppelin, etc...
Here's my SQL statent for my listbox:
SELECT DISTINCTROW [Bands].[BandNumber], [Bands].[BandName]
FROM [Bands]
WHERE ((([Bands].[BandName]) Like "[forms]![frmSearch]![txtLetter]*"))
ORDER BY [Bands].[BandName];
Is my criteria for BandName OK? Or am I using it wrong?
Like "[forms]![frmSearch]![txtLetter]*"
So after I figure how to get this to work, I gotta figure out how to
get the selected record to open a form that has general information
about the band.
Thanks for reading my post!!!
Megan 9 6872
What you describe is how a Combo Box works with the default setting of Yes
for AutoExpand. It does it automatically, and has the advantage of catching
misspellings as it scrolls to the next matching entry as you type. That is,
set its "Limit to List" property to Yes, and make its RowSource a query that
returns just one (Unique Fields) entry for each of the groups in your
database.
I suppose it might be an interesting exercise to re-implement the
functionality using a Text Box, but there are many interesting exercises
that don't require re-inventing what Access provides.
Larry Linson
Microsoft Access MVP
"Megan" <me**************@hotmail.com> wrote in message
news:5c**************************@posting.google.c om... Hi-
I'm creating a database of music bands with their cds and songs.
I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with the selected record in the listbox.
For example:
If I enter the letter, "L," in my textbox and press the 'Enter' key, I'd like the bands that start with the letter, "L," to appear in the listbox, i.e. Limp Bizkit, Led Zeppelin, etc...
Here's my SQL statent for my listbox:
SELECT DISTINCTROW [Bands].[BandNumber], [Bands].[BandName] FROM [Bands] WHERE ((([Bands].[BandName]) Like "[forms]![frmSearch]![txtLetter]*")) ORDER BY [Bands].[BandName];
Is my criteria for BandName OK? Or am I using it wrong?
Like "[forms]![frmSearch]![txtLetter]*"
So after I figure how to get this to work, I gotta figure out how to get the selected record to open a form that has general information about the band.
Thanks for reading my post!!!
Megan
Hi Larry-
First let me say thanks for reading my post and replying.
Maybe you misunderstood what I meant, or maybe I wasn't clear enough.
I just want to enter the first letter of a band, i.e. "S" for Simpson,
Jessica and Spears, Brittany. I don't want to spell-out the entire
band name. I'd just like to enter a letter into a text box and then
see all of the bands that start with that letter. I don't want the
band names to automatically appear in the text box like it would in a
combo box. Gosh, I thought this might be easy to do.
I was doing some searching and came across this example:
SELECT fld FROM table WHERE fld Like
Forms!theform.textbox.Text & "*" ORDER BY fld
Use the text box's Change event to sync with the list box:
Me.listbox.Requery
NOTE: I apologize to the person who wrote this code. I forgot where I
saw it, but I wrote down his/ her example. I usually like to credit
the person I learned from. I'll try to find out where I saw this code.
I tried this code, but after I enter a letter into the text box and
press "Enter" the focus moves to the next control, and nothing appears
in my listbox.
Thanks,
Megan
"Larry Linson" <bo*****@localhost.not> wrote in message news:<hF******************@nwrddc02.gnilink.net>.. . What you describe is how a Combo Box works with the default setting of Yes for AutoExpand. It does it automatically, and has the advantage of catching misspellings as it scrolls to the next matching entry as you type. That is, set its "Limit to List" property to Yes, and make its RowSource a query that returns just one (Unique Fields) entry for each of the groups in your database.
I suppose it might be an interesting exercise to re-implement the functionality using a Text Box, but there are many interesting exercises that don't require re-inventing what Access provides.
Larry Linson Microsoft Access MVP
"Megan" <me**************@hotmail.com> wrote in message news:5c**************************@posting.google.c om... Hi-
I'm creating a database of music bands with their cds and songs.
I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with the selected record in the listbox.
For example:
If I enter the letter, "L," in my textbox and press the 'Enter' key, I'd like the bands that start with the letter, "L," to appear in the listbox, i.e. Limp Bizkit, Led Zeppelin, etc...
Here's my SQL statent for my listbox:
SELECT DISTINCTROW [Bands].[BandNumber], [Bands].[BandName] FROM [Bands] WHERE ((([Bands].[BandName]) Like "[forms]![frmSearch]![txtLetter]*")) ORDER BY [Bands].[BandName];
Is my criteria for BandName OK? Or am I using it wrong?
Like "[forms]![frmSearch]![txtLetter]*"
So after I figure how to get this to work, I gotta figure out how to get the selected record to open a form that has general information about the band.
Thanks for reading my post!!!
Megan
Hi everybody-
I just wanted to say that I got this working the way I wanted. I can
type in a letter in a text box, hit "Enter," and have the listbox
populated by bands starting with that letter.
It didn't work well or as planned using the On Change event of the
text box. So I tried the After Update Event of the text box, and it
works as I hoped.
Here's the code:
SELECT fld FROM table WHERE fld Like
Forms!theform.textbox.Text & "*" ORDER BY fld
Use the text box's After Update event to sync with the list box:
Me.listbox.Requery
NOTE: this is not my code. I found it in a post in
microsoft.public.access.formscoding. It was posted by "Marshall
Barton" opn 3-11-2004. Shout out to you Marsh!!! http://groups.google.com/groups?q=te...4ax.com&rnum=7
Megan me**************@hotmail.com (Megan) wrote in message news:<5c**************************@posting.google. com>... Hi-
I'm creating a database of music bands with their cds and songs.
I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with the selected record in the listbox.
For example:
If I enter the letter, "L," in my textbox and press the 'Enter' key, I'd like the bands that start with the letter, "L," to appear in the listbox, i.e. Limp Bizkit, Led Zeppelin, etc...
Here's my SQL statent for my listbox:
SELECT DISTINCTROW [Bands].[BandNumber], [Bands].[BandName] FROM [Bands] WHERE ((([Bands].[BandName]) Like "[forms]![frmSearch]![txtLetter]*")) ORDER BY [Bands].[BandName];
Is my criteria for BandName OK? Or am I using it wrong?
Like "[forms]![frmSearch]![txtLetter]*"
So after I figure how to get this to work, I gotta figure out how to get the selected record to open a form that has general information about the band.
Thanks for reading my post!!!
Megan
"Megan" <me**************@hotmail.com> wrote in message
news:5c**************************@posting.google.c om... I was doing some searching and came across this example:
SELECT fld FROM table WHERE fld Like Forms!theform.textbox.Text & "*" ORDER BY fld
Use the text box's Change event to sync with the list box:
Me.listbox.Requery
NOTE: I apologize to the person who wrote this code. I forgot where I saw it, but I wrote down his/ her example. I usually like to credit the person I learned from. I'll try to find out where I saw this code.
I tried this code, but after I enter a letter into the text box and press "Enter" the focus moves to the next control, and nothing appears in my listbox.
Does your query return the correct results when run in the query builder?
That's where you should begin your quest to get things working.
Are you sure the listbox rowsource is set correctly?
Are you sure you are referencing the .Text property of the textbox
specifically in the query? Nothing will happen in the Change Event
if you're referencing the .Value property.
Hey RKC-
thanks for the suggestion! I tried it your way, and it works even
better than my solution! And it does more!
Thanks a bunch!
Megan
"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in message news:<eE******************@twister.nyroc.rr.com>.. . "Megan" <me**************@hotmail.com> wrote in message news:5c**************************@posting.google.c om...
Does your query return the correct results when run in the query builder? That's where you should begin your quest to get things working.
Are you sure the listbox rowsource is set correctly?
Are you sure you are referencing the .Text property of the textbox specifically in the query? Nothing will happen in the Change Event if you're referencing the .Value property.
Hi-
I've encountered a new problem. After I type letters in my text box to
populate my listbox, I click my command button to open a form with the
selected record and I get a pop-up box that asks for the criteria of
my listbox query.
Enter Parameter Value:
Forms!frmSearch.txtLetter.Text
If I hit "OK" or "Cancel" the form opens up alright with the correct
record selected in my listbox.
Here's some of the code behind my command button. I have 2 listboxes
on my form. After I type in "L" then "I" for "LI" in my text box,
txtLetter, the listbox is populated with the bands: Limp Bizkit and
Linkin Park. If I select either band, then click my command button to
open a form, then I get the "Enter Parameter Box" pops up.
I use a nestled IF statement to determine which listbox is being used.
Here's the part that runs if I select a Band Name:
ElseIf Me.lstAssignedHearings.ItemsSelected.Count > 0 Then
strg = Int(Me.lstBandNames)
code = "[BandNumber] = " & strg & " "
DoCmd.Close
DoCmd.OpenForm FormName:="frmAlbums", wherecondition:=code
End If
I'm trying to figure out why that Parameter Box pops up?
Thanks,
Megan me**************@hotmail.com (Megan) wrote in message news:<5c**************************@posting.google. com>... Hi everybody-
I just wanted to say that I got this working the way I wanted. I can type in a letter in a text box, hit "Enter," and have the listbox populated by bands starting with that letter.
It didn't work well or as planned using the On Change event of the text box. So I tried the After Update Event of the text box, and it works as I hoped.
Here's the code:
SELECT fld FROM table WHERE fld Like Forms!theform.textbox.Text & "*" ORDER BY fld
Use the text box's After Update event to sync with the list box:
Me.listbox.Requery
NOTE: this is not my code. I found it in a post in microsoft.public.access.formscoding. It was posted by "Marshall Barton" opn 3-11-2004. Shout out to you Marsh!!!
http://groups.google.com/groups?q=te...4ax.com&rnum=7
Megan me**************@hotmail.com (Megan) wrote in message news:<5c**************************@posting.google. com>... Hi-
I'm creating a database of music bands with their cds and songs.
I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with the selected record in the listbox.
For example:
If I enter the letter, "L," in my textbox and press the 'Enter' key, I'd like the bands that start with the letter, "L," to appear in the listbox, i.e. Limp Bizkit, Led Zeppelin, etc...
Here's my SQL statent for my listbox:
SELECT DISTINCTROW [Bands].[BandNumber], [Bands].[BandName] FROM [Bands] WHERE ((([Bands].[BandName]) Like "[forms]![frmSearch]![txtLetter]*")) ORDER BY [Bands].[BandName];
Is my criteria for BandName OK? Or am I using it wrong?
Like "[forms]![frmSearch]![txtLetter]*"
So after I figure how to get this to work, I gotta figure out how to get the selected record to open a form that has general information about the band.
Thanks for reading my post!!!
Megan
> I've encountered a new problem. After I type letters in my text box to populate my listbox, I click my command button to open a form with the selected record and I get a pop-up box that asks for the criteria of my listbox query.
Enter Parameter Value: Forms!frmSearch.txtLetter.Text
If I hit "OK" or "Cancel" the form opens up alright with the correct record selected in my listbox.
Here's some of the code behind my command button. I have 2 listboxes on my form. After I type in "L" then "I" for "LI" in my text box, txtLetter, the listbox is populated with the bands: Limp Bizkit and Linkin Park. If I select either band, then click my command button to open a form, then I get the "Enter Parameter Box" pops up.
I use a nestled IF statement to determine which listbox is being used. Here's the part that runs if I select a Band Name:
ElseIf Me.lstAssignedHearings.ItemsSelected.Count > 0 Then strg = Int(Me.lstBandNames) code = "[BandNumber] = " & strg & " " DoCmd.Close DoCmd.OpenForm FormName:="frmAlbums", wherecondition:=code End If
I'm trying to figure out why that Parameter Box pops up?
If you're not using the Multi-select property of the listbox, use a
combobox and save yourself a LOT of headaches. Otherwise, use the
code at www.mvps.org to iterate through the ItemsSelected collection
of the listbox to create your filter/where condition.
Problem: I get an "Enter Parameter Value" box after I fill a listbox,
select a record, and use a command button to open the selected record
in a form.
Solution: Well, I found a way around this, but I don't think it is the
best way to handle it. I added this line of code:
Me.lstBandNames.RowSource = ""
I added it to my nestled If statement:
ElseIf Me.lstBandNames.ItemsSelected.Count > 0 Then
strg = Int(Me.lstBandNames)
code = "[BandNumber] = " & strg & " "
Me.lstBandNames.RowSource
DoCmd.Close
DoCmd.OpenForm FormName:="frmAlbums", wherecondition:=code
End If
Even though this works, I was wondering if there is a better way to do
this, or if my code is just bad. :-)
Thanks,
Megan me**************@hotmail.com (Megan) wrote in message news:<5c**************************@posting.google. com>... Hi-
I've encountered a new problem. After I type letters in my text box to populate my listbox, I click my command button to open a form with the selected record and I get a pop-up box that asks for the criteria of my listbox query.
Enter Parameter Value: Forms!frmSearch.txtLetter.Text
If I hit "OK" or "Cancel" the form opens up alright with the correct record selected in my listbox.
Here's some of the code behind my command button. I have 2 listboxes on my form. After I type in "L" then "I" for "LI" in my text box, txtLetter, the listbox is populated with the bands: Limp Bizkit and Linkin Park. If I select either band, then click my command button to open a form, then I get the "Enter Parameter Box" pops up.
I use a nestled IF statement to determine which listbox is being used. Here's the part that runs if I select a Band Name:
ElseIf Me.lstAssignedHearings.ItemsSelected.Count > 0 Then strg = Int(Me.lstBandNames) code = "[BandNumber] = " & strg & " " DoCmd.Close DoCmd.OpenForm FormName:="frmAlbums", wherecondition:=code End If
I'm trying to figure out why that Parameter Box pops up?
Thanks,
Megan
me**************@hotmail.com (Megan) wrote in message news:<5c**************************@posting.google. com>... Hi everybody-
I just wanted to say that I got this working the way I wanted. I can type in a letter in a text box, hit "Enter," and have the listbox populated by bands starting with that letter.
It didn't work well or as planned using the On Change event of the text box. So I tried the After Update Event of the text box, and it works as I hoped.
Here's the code:
SELECT fld FROM table WHERE fld Like Forms!theform.textbox.Text & "*" ORDER BY fld
Use the text box's After Update event to sync with the list box:
Me.listbox.Requery
NOTE: this is not my code. I found it in a post in microsoft.public.access.formscoding. It was posted by "Marshall Barton" opn 3-11-2004. Shout out to you Marsh!!!
http://groups.google.com/groups?q=te...4ax.com&rnum=7
Megan me**************@hotmail.com (Megan) wrote in message news:<5c**************************@posting.google. com>... Hi-
I'm creating a database of music bands with their cds and songs.
I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with the selected record in the listbox.
For example:
If I enter the letter, "L," in my textbox and press the 'Enter' key, I'd like the bands that start with the letter, "L," to appear in the listbox, i.e. Limp Bizkit, Led Zeppelin, etc...
Here's my SQL statent for my listbox:
SELECT DISTINCTROW [Bands].[BandNumber], [Bands].[BandName] FROM [Bands] WHERE ((([Bands].[BandName]) Like "[forms]![frmSearch]![txtLetter]*")) ORDER BY [Bands].[BandName];
Is my criteria for BandName OK? Or am I using it wrong?
Like "[forms]![frmSearch]![txtLetter]*"
So after I figure how to get this to work, I gotta figure out how to get the selected record to open a form that has general information about the band.
Thanks for reading my post!!!
Megan
Thanks everybody for your time and for reading my post!
I found a solution to my problem. I don't know if this is the best way
to do this, but I kind of tricked the Enter Parameter Value box by
setting the rowsource to "" in my code.
I added the following line of code to my nested IF statement:
Me.lstBandNames.RowSource = ""
BEFORE:
ElseIf Me.lstBandNames.ItemsSelected.Count > 0 Then
strg = Int(Me.lstBandNames)
code = "[BandNumber] = " & strg & " "
DoCmd.Close
DoCmd.OpenForm FormName:="frmAlbums", wherecondition:=code
End If
AFTER:
ElseIf Me.lstBandNames.ItemsSelected.Count > 0 Then
strg = Int(Me.lstBandNames)
code = "[BandNumber] = " & strg & " "
Me.lstBandNames.Rowsource = ""
DoCmd.Close
DoCmd.OpenForm FormName:="frmAlbums", wherecondition:=code
End If
I don't know if this is the best way to do what I want to do, but I'm
new to listboxes and VBA code. I'm reading about "multi-select
listboxes" and "FOR" loops. So hopefully, I'll get better soon.
Thanks everybody. I posted my solution because I hope this might be
able to help someone else!
Megan me**************@hotmail.com (Megan) wrote in message news:<5c**************************@posting.google. com>... Hi-
I've encountered a new problem. After I type letters in my text box to populate my listbox, I click my command button to open a form with the selected record and I get a pop-up box that asks for the criteria of my listbox query.
Enter Parameter Value: Forms!frmSearch.txtLetter.Text
If I hit "OK" or "Cancel" the form opens up alright with the correct record selected in my listbox.
Here's some of the code behind my command button. I have 2 listboxes on my form. After I type in "L" then "I" for "LI" in my text box, txtLetter, the listbox is populated with the bands: Limp Bizkit and Linkin Park. If I select either band, then click my command button to open a form, then I get the "Enter Parameter Box" pops up.
I use a nestled IF statement to determine which listbox is being used. Here's the part that runs if I select a Band Name:
ElseIf Me.lstBandNames.ItemsSelected.Count > 0 Then strg = Int(Me.lstBandNames) code = "[BandNumber] = " & strg & " " DoCmd.Close DoCmd.OpenForm FormName:="frmAlbums", wherecondition:=code End If
I'm trying to figure out why that Parameter Box pops up?
Thanks,
Megan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ebba Cecilia Ovesdotter Alm |
last post by:
Hello,
I'm learning how to use the Tkinter module. I would like to
use an element similar to a drop-down form,
where the user can select one option out of many. I thought
that a Listbox item...
|
by: Mike |
last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or
comments on how to make this work I would be grateful! I have been working
on this for the past 4 days and nothing I do...
|
by: Randel Bjorkquist |
last post by:
I'm completely lost and need some help to understand how the Visual Studios
data components work, deals with database, datsets, datasources, etc... I'm
extremely new to Visual Studio and am having...
|
by: Daniel |
last post by:
I'm new to .Net and all of its abilities so I hope this makes sense.
Basically I'm confused on when is the appropriate time to use web forms
controls vs. regular HTML.
For example in ASP...
|
by: yma |
last post by:
Hi,
I tried to use a listbox to display a column in MS Access 2000 nwind.mdb by
using ole DataAdapter, Connection and dataset controls. But I got "It is
already opened exclusively by another...
|
by: amber |
last post by:
Hello
I'm trying to run the code below, but I'm running into a problem
It is populating a listbox, based on whether or not the user enters data into a text box. If they enter something, it returns...
|
by: Allen |
last post by:
Hey all, I have a question for you all. I'm learning vb.net and need some
help. I have two classes one named Customers and one named CustomersDA. I
have to go though Customer for everything. I have...
|
by: Allen |
last post by:
I have a class that returns an arraylist. How do I fill a list box from what
is returned? It returns customers which is a arraylist but I cant seem to
get the stuff to fill a list box. I just...
|
by: frank |
last post by:
Hello All,
I know this is a re-post, but I didn't get any bites on my last post. So here goes again:
I have a listbox which is bound to a datatable. I have set the displaymember and valuemember...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |