By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,563 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Updating a Listbox

P: n/a
I have have two list boxes. One is a listing of all possible variables.
We'll call this listbox A. The other is a listing of all the selected
variables. We'll call this listbox B. If a person double-clicks on one of
the variables in listbox A it "moves" it to listbox B. What is going on
behind the scenes is that the table that holds all these variables has a
yes/no field call Print. When the user double clicks on the value it fires
a db.execute statement which is an Update SQL statement to put it in the
right state, either yes or no. This all works fine and dandy. What I'm
having a problem with though is that based on what values are chosen (those
in listbox B) other textboxes and option groups become enabled or disabled.
I put some code in the After Update event of listbox B which goes like this:

Private Sub lstPatronTypesInclude_AfterUpdate()

For x = 0 To lstPatronTypesInclude.ListCount
If Me!lstPatronTypesInclude.ItemData(x) = 6 Then
txtMembershipExpiredFrom.Enabled = True
Exit Sub
Else
txtMembershipExpiredFrom.Enabled = False
End If
Next x

End Sub

The problem is is that it only fires when I've clicked back onto listbox B.
So I could click away and all the variables I want, but if I don't click
onto listbox B, the other text boxes on the form don't change to enabled or
disabled. Is there a way to get this to happen or am I gooing about this
the entirely wrong way?

TIA,
Bill
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Have you tried using the code in the 'Click' event of the list box...
"Bill" <zi*****@hotmail.com> wrote in message
news:vo************@corp.supernews.com...
I have have two list boxes. One is a listing of all possible variables.
We'll call this listbox A. The other is a listing of all the selected
variables. We'll call this listbox B. If a person double-clicks on one of the variables in listbox A it "moves" it to listbox B. What is going on
behind the scenes is that the table that holds all these variables has a
yes/no field call Print. When the user double clicks on the value it fires a db.execute statement which is an Update SQL statement to put it in the
right state, either yes or no. This all works fine and dandy. What I'm
having a problem with though is that based on what values are chosen (those in listbox B) other textboxes and option groups become enabled or disabled. I put some code in the After Update event of listbox B which goes like this:
Private Sub lstPatronTypesInclude_AfterUpdate()

For x = 0 To lstPatronTypesInclude.ListCount
If Me!lstPatronTypesInclude.ItemData(x) = 6 Then
txtMembershipExpiredFrom.Enabled = True
Exit Sub
Else
txtMembershipExpiredFrom.Enabled = False
End If
Next x

End Sub

The problem is is that it only fires when I've clicked back onto listbox B. So I could click away and all the variables I want, but if I don't click
onto listbox B, the other text boxes on the form don't change to enabled or disabled. Is there a way to get this to happen or am I gooing about this
the entirely wrong way?

TIA,
Bill

Nov 12 '05 #2

P: n/a
You didn't give details of "moving the value to Listbox B", but it would
appear that doing so does not fire Listbox B's AfterUpdate event -- try
putting the code in the DoubleClick of Listbox A, after "moving" it to
Listbox B.

Larry Linson
Microsoft Access MVP

"Bill" <zi*****@hotmail.com> wrote in message
news:vo************@corp.supernews.com...
I have have two list boxes. One is a listing of all possible variables.
We'll call this listbox A. The other is a listing of all the selected
variables. We'll call this listbox B. If a person double-clicks on one of the variables in listbox A it "moves" it to listbox B. What is going on
behind the scenes is that the table that holds all these variables has a
yes/no field call Print. When the user double clicks on the value it fires a db.execute statement which is an Update SQL statement to put it in the
right state, either yes or no. This all works fine and dandy. What I'm
having a problem with though is that based on what values are chosen (those in listbox B) other textboxes and option groups become enabled or disabled. I put some code in the After Update event of listbox B which goes like this:
Private Sub lstPatronTypesInclude_AfterUpdate()

For x = 0 To lstPatronTypesInclude.ListCount
If Me!lstPatronTypesInclude.ItemData(x) = 6 Then
txtMembershipExpiredFrom.Enabled = True
Exit Sub
Else
txtMembershipExpiredFrom.Enabled = False
End If
Next x

End Sub

The problem is is that it only fires when I've clicked back onto listbox B. So I could click away and all the variables I want, but if I don't click
onto listbox B, the other text boxes on the form don't change to enabled or disabled. Is there a way to get this to happen or am I gooing about this
the entirely wrong way?

TIA,
Bill

Nov 12 '05 #3

P: n/a
I'm not sure I understand. I don't want to have to click on the list box.
When I move the the variable from the list of all variables to the list of
selected variables (through double clicking the "all-variables" list box) I
want to have the appropriate text boxes on the form to become active. It
doesn't become active until I have moved it over and then click on the
listbox of selected variable. Basically what is happening is the after
update event doesn't fire until i actually click on the list box.
"Ruskin Hardie" <Ru******@xtra.NOSPAM.co.nz> wrote in message
news:gW**********************@news.xtra.co.nz...
Have you tried using the code in the 'Click' event of the list box...
"Bill" <zi*****@hotmail.com> wrote in message
news:vo************@corp.supernews.com...
I have have two list boxes. One is a listing of all possible variables.
We'll call this listbox A. The other is a listing of all the selected
variables. We'll call this listbox B. If a person double-clicks on one

of
the variables in listbox A it "moves" it to listbox B. What is going on
behind the scenes is that the table that holds all these variables has a
yes/no field call Print. When the user double clicks on the value it

fires
a db.execute statement which is an Update SQL statement to put it in the
right state, either yes or no. This all works fine and dandy. What I'm
having a problem with though is that based on what values are chosen

(those
in listbox B) other textboxes and option groups become enabled or

disabled.
I put some code in the After Update event of listbox B which goes like

this:

Private Sub lstPatronTypesInclude_AfterUpdate()

For x = 0 To lstPatronTypesInclude.ListCount
If Me!lstPatronTypesInclude.ItemData(x) = 6 Then
txtMembershipExpiredFrom.Enabled = True
Exit Sub
Else
txtMembershipExpiredFrom.Enabled = False
End If
Next x

End Sub

The problem is is that it only fires when I've clicked back onto listbox

B.
So I could click away and all the variables I want, but if I don't click
onto listbox B, the other text boxes on the form don't change to enabled

or
disabled. Is there a way to get this to happen or am I gooing about this the entirely wrong way?

TIA,
Bill


Nov 12 '05 #4

P: n/a
So put the code, in the event of the "all-variables" list box, that causes
the value to move to the "selected variables" list box (ie: the double_click
event of the all-variables list box)...

"Bill" <zi*****@hotmail.com> wrote in message
news:vo************@corp.supernews.com...
I'm not sure I understand. I don't want to have to click on the list box.
When I move the the variable from the list of all variables to the list of
selected variables (through double clicking the "all-variables" list box) I want to have the appropriate text boxes on the form to become active. It
doesn't become active until I have moved it over and then click on the
listbox of selected variable. Basically what is happening is the after
update event doesn't fire until i actually click on the list box.
"Ruskin Hardie" <Ru******@xtra.NOSPAM.co.nz> wrote in message
news:gW**********************@news.xtra.co.nz...
Have you tried using the code in the 'Click' event of the list box...
"Bill" <zi*****@hotmail.com> wrote in message
news:vo************@corp.supernews.com...
I have have two list boxes. One is a listing of all possible variables. We'll call this listbox A. The other is a listing of all the selected
variables. We'll call this listbox B. If a person double-clicks on one
of
the variables in listbox A it "moves" it to listbox B. What is going
on behind the scenes is that the table that holds all these variables has a yes/no field call Print. When the user double clicks on the value it

fires
a db.execute statement which is an Update SQL statement to put it in the right state, either yes or no. This all works fine and dandy. What I'm having a problem with though is that based on what values are chosen

(those
in listbox B) other textboxes and option groups become enabled or

disabled.
I put some code in the After Update event of listbox B which goes like

this:

Private Sub lstPatronTypesInclude_AfterUpdate()

For x = 0 To lstPatronTypesInclude.ListCount
If Me!lstPatronTypesInclude.ItemData(x) = 6 Then
txtMembershipExpiredFrom.Enabled = True
Exit Sub
Else
txtMembershipExpiredFrom.Enabled = False
End If
Next x

End Sub

The problem is is that it only fires when I've clicked back onto listbox
B.
So I could click away and all the variables I want, but if I don't
click onto listbox B, the other text boxes on the form don't change to

enabled or
disabled. Is there a way to get this to happen or am I gooing about

this the entirely wrong way?

TIA,
Bill



Nov 12 '05 #5

P: n/a
oh...heh...well that would be just too dang easy, now wouldn't it?
Thanks...worked perfectly. :)
"Ruskin Hardie" <Ru******@xtra.NOSPAM.co.nz> wrote in message
news:sJ**********************@news.xtra.co.nz...
So put the code, in the event of the "all-variables" list box, that causes
the value to move to the "selected variables" list box (ie: the double_click event of the all-variables list box)...

"Bill" <zi*****@hotmail.com> wrote in message
news:vo************@corp.supernews.com...
I'm not sure I understand. I don't want to have to click on the list box.
When I move the the variable from the list of all variables to the list of selected variables (through double clicking the "all-variables" list box)
I
want to have the appropriate text boxes on the form to become active.
It doesn't become active until I have moved it over and then click on the
listbox of selected variable. Basically what is happening is the after
update event doesn't fire until i actually click on the list box.
"Ruskin Hardie" <Ru******@xtra.NOSPAM.co.nz> wrote in message
news:gW**********************@news.xtra.co.nz...
Have you tried using the code in the 'Click' event of the list box...
"Bill" <zi*****@hotmail.com> wrote in message
news:vo************@corp.supernews.com...
> I have have two list boxes. One is a listing of all possible

variables. > We'll call this listbox A. The other is a listing of all the selected > variables. We'll call this listbox B. If a person double-clicks on one of
> the variables in listbox A it "moves" it to listbox B. What is going on
> behind the scenes is that the table that holds all these variables
has
a > yes/no field call Print. When the user double clicks on the value
it fires
> a db.execute statement which is an Update SQL statement to put it in

the > right state, either yes or no. This all works fine and dandy. What I'm > having a problem with though is that based on what values are chosen
(those
> in listbox B) other textboxes and option groups become enabled or
disabled.
> I put some code in the After Update event of listbox B which goes like this:
>
> Private Sub lstPatronTypesInclude_AfterUpdate()
>
> For x = 0 To lstPatronTypesInclude.ListCount
> If Me!lstPatronTypesInclude.ItemData(x) = 6 Then
> txtMembershipExpiredFrom.Enabled = True
> Exit Sub
> Else
> txtMembershipExpiredFrom.Enabled = False
> End If
> Next x
>
> End Sub
>
> The problem is is that it only fires when I've clicked back onto listbox B.
> So I could click away and all the variables I want, but if I don't click > onto listbox B, the other text boxes on the form don't change to enabled or
> disabled. Is there a way to get this to happen or am I gooing about

this
> the entirely wrong way?
>
> TIA,
> Bill
>
>



Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.