listbox selection

R

Rob

In an old version of access I used some code to make a
selection by using 2 listboxes. first listbox contains the
nonselected items and the second the selected items. With
the items in the second listbos I want to run a query.

I have some code but this does not work for access97, can
sombody help me to translate?

Function NSPCdoubleclick()

Dim ds As Dynaset, db As Database

Set db = CurrentDb()
MyType$ = Forms!Form_Selection!PCNotSelected.Column(0)
Set ds = db.CreateDynaset("select * from [Product
category] where [ProductCatDescription] = '" + MyType$
+ "';")

ds.Edit
ds.[Selected] = True
ds.UPDATE
ds.Close

DoCmd.Requery "PCNotSelected" ' listbox1
DoCmd.Requery "PCSelected" ' listbox2

Exit Function

/Rob
 
D

Dan Artuso

Hi,
You could try this:

Function NSPCdoubleclick()

Dim ds As DAO.Recordset
Dim db As DAO.Database

Set db = CurrentDb()
MyType$ = Forms!Form_Selection!PCNotSelected.Column(0)
Set ds = db.OpenRecordset("select * from [Product category] where " & _
"[ProductCatDescription] = '" & MyType$ & "';")

ds.Edit
ds.[Selected] = True
ds.UPDATE
ds.Close

DoCmd.Requery "PCNotSelected" ' listbox1
DoCmd.Requery "PCSelected" ' listbox2

Exit Function
 
R

Rob

Thanks...

-----Original Message-----
Hi,
You could try this:

Function NSPCdoubleclick()

Dim ds As DAO.Recordset
Dim db As DAO.Database

Set db = CurrentDb()
MyType$ = Forms!Form_Selection!PCNotSelected.Column(0)
Set ds = db.OpenRecordset("select * from [Product category] where " & _
"[ProductCatDescription] = '" & MyType$ & "';")

ds.Edit
ds.[Selected] = True
ds.UPDATE
ds.Close

DoCmd.Requery "PCNotSelected" ' listbox1
DoCmd.Requery "PCSelected" ' listbox2

Exit Function


--
HTH
Dan Artuso, Access MVP


"Rob" <[email protected]> wrote in
message news:[email protected]...
In an old version of access I used some code to make a
selection by using 2 listboxes. first listbox contains the
nonselected items and the second the selected items. With
the items in the second listbos I want to run a query.

I have some code but this does not work for access97, can
sombody help me to translate?

Function NSPCdoubleclick()

Dim ds As Dynaset, db As Database

Set db = CurrentDb()
MyType$ = Forms!Form_Selection!PCNotSelected.Column(0)
Set ds = db.CreateDynaset("select * from [Product
category] where [ProductCatDescription] = '" + MyType$
+ "';")

ds.Edit
ds.[Selected] = True
ds.UPDATE
ds.Close

DoCmd.Requery "PCNotSelected" ' listbox1
DoCmd.Requery "PCSelected" ' listbox2

Exit Function

/Rob


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top