listbox selection

  • Thread starter Thread starter Rob
  • Start date Start date
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
 
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
 
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


.
 
Back
Top