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
meganrobertson22@hotmail.com (Megan) wrote in message news:<5c14c12b.0406250944.4153106f@posting.google. com>...[color=blue]
> 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
>
>
>
>
>
meganrobertson22@hotmail.com (Megan) wrote in message news:<5c14c12b.0406220954.7243b038@posting.google. com>...[color=green]
> > 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
> >
> >
> >
meganrobertson22@hotmail.com (Megan) wrote in message news:<5c14c12b.0406211811.2f0e3bfc@posting.google. com>...[color=darkred]
> > > 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[/color][/color][/color]