473,473 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Simple listbox query question

Hello

Simple one this I guess, but I'm quite stuck at the moment.

I would like to update the records displayed in my listbox
(lstStudents) using criteria selected from my combo (cboForm) in a
form.

My basic code is:

Private Sub cboForm_AfterUpdate()

Dim Form As String
Form = cboForm.Column(1) 'A simple list of all the available forms
lstStudents.Column(7) = Form 'This is the relevant column in the
underlying query that lists the student's form

End Sub

I've tried declaring the variable as a variant too but all I keep
getting is Error 424 object required. I've msgbox'd my variable and
it is correct but it can't be used as the appropriate criteria for the
listbox. Help!

many thanks

David

Oct 5 '07 #1
3 2454
On Fri, 05 Oct 2007 13:23:24 -0000, deejayquai <de********@gmail.com>
wrote:

Don't use a reserved word like Form as a variable name.

No need to MsgBox your variable. Use the debugger.

Listboxes are readonly. If you want to update them, the procedure is
to update the underlying RowSource with an Update query, and then
requery the listbox so the changes will show.

-Tom.

>Hello

Simple one this I guess, but I'm quite stuck at the moment.

I would like to update the records displayed in my listbox
(lstStudents) using criteria selected from my combo (cboForm) in a
form.

My basic code is:

Private Sub cboForm_AfterUpdate()

Dim Form As String
Form = cboForm.Column(1) 'A simple list of all the available forms
lstStudents.Column(7) = Form 'This is the relevant column in the
underlying query that lists the student's form

End Sub

I've tried declaring the variable as a variant too but all I keep
getting is Error 424 object required. I've msgbox'd my variable and
it is correct but it can't be used as the appropriate criteria for the
listbox. Help!

many thanks

David
Oct 5 '07 #2
On 5 Oct, 15:10, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On Fri, 05 Oct 2007 13:23:24 -0000, deejayquai <deejayq...@gmail.com>
wrote:

Don't use a reserved word like Form as a variable name.

No need to MsgBox your variable. Use the debugger.

Listboxes are readonly. If you want to update them, the procedure is
to update the underlying RowSource with an Update query, and then
requery the listbox so the changes will show.

-Tom.
Hello
Simple one this I guess, but I'm quite stuck at the moment.
I would like to update the records displayed in my listbox
(lstStudents) using criteria selected from my combo (cboForm) in a
form.
My basic code is:
Private Sub cboForm_AfterUpdate()
Dim Form As String
Form = cboForm.Column(1) 'A simple list of all the available forms
lstStudents.Column(7) = Form 'This is the relevant column in the
underlying query that lists the student's form
End Sub
I've tried declaring the variable as a variant too but all I keep
getting is Error 424 object required. I've msgbox'd my variable and
it is correct but it can't be used as the appropriate criteria for the
listbox. Help!
many thanks
David- Hide quoted text -

- Show quoted text -
Thanks, but don't go away- how do I update the underlying rowsource
with an update query...! (sorry)

David

Oct 5 '07 #3
On 5 Oct, 15:17, deejayquai <deejayq...@gmail.comwrote:
On 5 Oct, 15:10, Tom van Stiphout <no.spam.tom7...@cox.netwrote:


On Fri, 05 Oct 2007 13:23:24 -0000, deejayquai <deejayq...@gmail.com>
wrote:
Don't use a reserved word like Form as a variable name.
No need to MsgBox your variable. Use the debugger.
Listboxes are readonly. If you want to update them, the procedure is
to update the underlying RowSource with an Update query, and then
requery the listbox so the changes will show.
-Tom.
>Hello
>Simple one this I guess, but I'm quite stuck at the moment.
>I would like to update the records displayed in my listbox
>(lstStudents) using criteria selected from my combo (cboForm) in a
>form.
>My basic code is:
>Private Sub cboForm_AfterUpdate()
>Dim Form As String
>Form = cboForm.Column(1) 'A simple list of all the available forms
>lstStudents.Column(7) = Form 'This is the relevant column in the
>underlying query that lists the student's form
>End Sub
>I've tried declaring the variable as a variant too but all I keep
>getting is Error 424 object required. I've msgbox'd my variable and
>it is correct but it can't be used as the appropriate criteria for the
>listbox. Help!
>many thanks
>David- Hide quoted text -
- Show quoted text -

Thanks, but don't go away- how do I update the underlying rowsource
with an update query...! (sorry)

David- Hide quoted text -

- Show quoted text -
Actually, I need to apologise- I think I may have described my problem
incorrectly- what I would like to do is requery the list box based on
the selection I make in the combo- I don't want to change any of the
underlying data itself. So for example if I choose form 'E' from the
combo then the listbox autmatically requeries to only show students in
form E. The listbox has 8 columns- name, age, form etc so I'm trying
to use the combo to filter the listbox accordingly- sorry for the
confusion. I'm still stuck though.

David

Oct 5 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Eddie Smit | last post by:
field- field- surname town ---- ---- john NY john Vegas john Boston eddie Boston eddie New Orleans eddie NY
2
by: Colleyville Alan | last post by:
I have a listbox that is populated with info and when the user selects categories of things from the list, it brings up detailed items from which to choose. I want to be able to put a filter on...
2
by: Geir Baardsen | last post by:
Hi! From a listbox I'd like to send only selected items to a report. Items will include: OrderNr,Date,EmployeeNr from tblOrders ZipCode,City from tblZipCodes Name,Adr,ZipID from...
6
by: dkintheuk | last post by:
Hi all, I have a form with some unbound combo's and a list box that are used to requery the dataset behind the form. All was working fine until i added the list box. I have the record set...
3
by: deko | last post by:
Is there any way to limit the number of records loaded into a ListBox? I looked at qdf.MaxRecords (to apply to the query that is the RowSource of the ListBox) but that only applies to ODBC data...
0
by: Park via AccessMonster.com | last post by:
I am new to Access and am having a problem with a simple listbox. This listbox is in a subform and contains 5 options. I entered these in a value list. There are two behaviors that I don't know how...
13
by: Saber | last post by:
I did a lot of searches and read something about datagrids. But I couldn't find the answer of my simple question, how can I show only my desired columns of a table? for example I wrote this sql...
6
by: Paul | last post by:
Hi All, Framework 1.1 listbox control unable to DataBind I've been googling for an answer to this query that appears quite a lot, but none, it seem, answers my problem directly. I am...
1
by: BerkshireGuy | last post by:
Ok - I have something I need help with and I am going to do my best to explain the siutation. I have a group of underwriters who can underwrite certain products. Some products they cannot...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.