Choosing values from a list box (1 Viewer)

seanog2001

Registered User.
Local time
Today, 07:24
Joined
Jun 26, 2006
Messages
67
I have a list box box which contains a ProNo and ProName.

I want to be able to select a value one list box and pass it to another list box in the form. I want to be able to do this using command buttons
eg the cmdbuttons you see on some access applicatuions that have the arrows < and > to move the data from one list box to the other and vice versa

Is this possible or is there another way of going about this problem.
 
Last edited:

Johny

Registered User.
Local time
Today, 08:24
Joined
Jun 1, 2004
Messages
80
Make a table with following fields:

ID (autoNr)
ProNo
ProName
Selected (Yes/No)

Make 2 queries based on this table:
qry1: Show selected records
qry2: Show not selected records

Make 2 lboxes and bind each lbox to another query.
When clicking the [>>] or [<<] button, just update the 'selected' field of the selected record (retrieve by ID) to invert boolean value and requery both listboxes.
It's really simple
 

seanog2001

Registered User.
Local time
Today, 07:24
Joined
Jun 26, 2006
Messages
67
what sort of code do i need to use behind the command buttons?
 

Johny

Registered User.
Local time
Today, 08:24
Joined
Jun 1, 2004
Messages
80
something like:

Code:
Dim db As Database
Dim rs As Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Selected FROM tblTABLENAME WHERE ID=" & Me.lb1)

With rs
    .Edit
    .Fields("Selected") = IIf(.Fields("Selected"), False, True)
    .Update
    
    .Close
End With

me.lb1.requery
me.lb2.requery
 

seanog2001

Registered User.
Local time
Today, 07:24
Joined
Jun 26, 2006
Messages
67
This returns an error too few parameters expected. on thisline of code

Set rs = db.OpenRecordset("SELECT Selected FROM projectlist WHERE ID=" & Me.List4)
 

Users who are viewing this thread

Top Bottom