Listbox problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to show results of a query in a listbox using a textbox to get the
parameter value. I've managed to write a QBF, which does run the query I
want using the textbox, but I want to see the reults in the lsitbox on the
form rather than in the table that Access produces when a parameter query is
run.

I have managed to get the list box to show the results but only if I switch
between design view and normal view, which really doesn't help as my user
isn't going want to do that every time they want to run a query.
 
If the query that the List box bound to look like that
Select Field1, Field2 from TableName Where Field3 =
Forms![Formname]![TextBoxName]

Then, on the after update event of the Text box, run the code
Me.[ListBoxName].Requery

Also, if you move between records, then put the line above on the On Current
event of the form.
 
This is what the query looks like that the list box is bound to

SELECT [QBF_Query].[ID], [QBF_Query].[Author], [QBF_Query].[Year],
[QBF_Query].[Title], [QBF_Query].[Location], [QBF_Query].[Location_2] FROM
[QBF_Query] ORDER BY [Author], [Year];

The QBF_Query looks like this:

SELECT References.ID, References.Author, References.Year, References.Title,
References.Location, References.Location_2
FROM [References]
WHERE (((References.Author) Like "*" & [Forms]![QBF_Form]![txtAuthor] &
"*")) OR ((([Forms]![QBF_Form]![txtAuthor]) Is Null))
ORDER BY References.Author, References.Year, References.Title;


I really have no idea what I'm doing wrong, I've tried you suggestion but
that just brings up a parameter query dialog box which is one of the stages
I'm trying to get round. If the code I've written give you some idea of
where I'm going wrong, and you can help, then I would be really grateful.



Ofer said:
If the query that the List box bound to look like that
Select Field1, Field2 from TableName Where Field3 =
Forms![Formname]![TextBoxName]

Then, on the after update event of the Text box, run the code
Me.[ListBoxName].Requery

Also, if you move between records, then put the line above on the On Current
event of the form.

--
I hope that helped
Good luck


diddydi said:
I want to show results of a query in a listbox using a textbox to get the
parameter value. I've managed to write a QBF, which does run the query I
want using the textbox, but I want to see the reults in the lsitbox on the
form rather than in the table that Access produces when a parameter query is
run.

I have managed to get the list box to show the results but only if I switch
between design view and normal view, which really doesn't help as my user
isn't going want to do that every time they want to run a query.
 
Why do you need this part ((([Forms]![QBF_Form]![txtAuthor]) Is Null))

try this

SELECT References.ID, References.Author, References.Year, References.Title,
References.Location, References.Location_2
FROM [References]
WHERE References.Author Like "*" & [Forms]![QBF_Form]![txtAuthor] &
"*" ORDER BY References.Author, References.Year, References.Title

And use the requery I suggested

--
I hope that helped
Good luck


diddydi said:
This is what the query looks like that the list box is bound to

SELECT [QBF_Query].[ID], [QBF_Query].[Author], [QBF_Query].[Year],
[QBF_Query].[Title], [QBF_Query].[Location], [QBF_Query].[Location_2] FROM
[QBF_Query] ORDER BY [Author], [Year];

The QBF_Query looks like this:

SELECT References.ID, References.Author, References.Year, References.Title,
References.Location, References.Location_2
FROM [References]
WHERE (((References.Author) Like "*" & [Forms]![QBF_Form]![txtAuthor] &
"*")) OR ((([Forms]![QBF_Form]![txtAuthor]) Is Null))
ORDER BY References.Author, References.Year, References.Title;


I really have no idea what I'm doing wrong, I've tried you suggestion but
that just brings up a parameter query dialog box which is one of the stages
I'm trying to get round. If the code I've written give you some idea of
where I'm going wrong, and you can help, then I would be really grateful.



Ofer said:
If the query that the List box bound to look like that
Select Field1, Field2 from TableName Where Field3 =
Forms![Formname]![TextBoxName]

Then, on the after update event of the Text box, run the code
Me.[ListBoxName].Requery

Also, if you move between records, then put the line above on the On Current
event of the form.

--
I hope that helped
Good luck


diddydi said:
I want to show results of a query in a listbox using a textbox to get the
parameter value. I've managed to write a QBF, which does run the query I
want using the textbox, but I want to see the reults in the lsitbox on the
form rather than in the table that Access produces when a parameter query is
run.

I have managed to get the list box to show the results but only if I switch
between design view and normal view, which really doesn't help as my user
isn't going want to do that every time they want to run a query.
 
Excellent, it works! Thank you.

The part about the txtAuthor box being null came from a set of code that was
on this website to do with creating Query By Form queries. I think it had to
be there because 2 text boxes were given in the example and either one or
both could be used to run the query. That's my next step really, hopefully
I'll be ok with it but if not I'll just come back and ask for help again.


Ofer said:
Why do you need this part ((([Forms]![QBF_Form]![txtAuthor]) Is Null))

try this

SELECT References.ID, References.Author, References.Year, References.Title,
References.Location, References.Location_2
FROM [References]
WHERE References.Author Like "*" & [Forms]![QBF_Form]![txtAuthor] &
"*" ORDER BY References.Author, References.Year, References.Title

And use the requery I suggested

--
I hope that helped
Good luck


diddydi said:
This is what the query looks like that the list box is bound to

SELECT [QBF_Query].[ID], [QBF_Query].[Author], [QBF_Query].[Year],
[QBF_Query].[Title], [QBF_Query].[Location], [QBF_Query].[Location_2] FROM
[QBF_Query] ORDER BY [Author], [Year];

The QBF_Query looks like this:

SELECT References.ID, References.Author, References.Year, References.Title,
References.Location, References.Location_2
FROM [References]
WHERE (((References.Author) Like "*" & [Forms]![QBF_Form]![txtAuthor] &
"*")) OR ((([Forms]![QBF_Form]![txtAuthor]) Is Null))
ORDER BY References.Author, References.Year, References.Title;


I really have no idea what I'm doing wrong, I've tried you suggestion but
that just brings up a parameter query dialog box which is one of the stages
I'm trying to get round. If the code I've written give you some idea of
where I'm going wrong, and you can help, then I would be really grateful.



Ofer said:
If the query that the List box bound to look like that
Select Field1, Field2 from TableName Where Field3 =
Forms![Formname]![TextBoxName]

Then, on the after update event of the Text box, run the code
Me.[ListBoxName].Requery

Also, if you move between records, then put the line above on the On Current
event of the form.

--
I hope that helped
Good luck


:

I want to show results of a query in a listbox using a textbox to get the
parameter value. I've managed to write a QBF, which does run the query I
want using the textbox, but I want to see the reults in the lsitbox on the
form rather than in the table that Access produces when a parameter query is
run.

I have managed to get the list box to show the results but only if I switch
between design view and normal view, which really doesn't help as my user
isn't going want to do that every time they want to run a query.
 
Back
Top