ListBox

asamy

New member
Local time
Today, 01:36
Joined
Nov 9, 2023
Messages
5
Hello,
I have a problem and I hope someone can help me..
I have a listbox with 5 columns one of these is a boolean(yes /no) the 5th one, I would like to change the value from no to yes of the selected row (with click or button). can anyone help me?
Thank you
 
Hi. Welcome to AWF!
 
@theDBguy ..Thank you
@MajP
Thanks for your quick response..
1. it's too much for the "program", I need something easy
2. yes it dose exist in table..
3. and 4 noooo
I need (if its possibile) easy and simple way by clicking on the row or vba code to change the value of the selected row/rows



I tried something some code but it went wrong

Thanks in advance

Samy
 
I have a listbox with 5 columns one of these is a boolean(yes /no) the 5th one, I would like to change the value from no to yes of the selected row (with click or button). can anyone help me?

Back in 2015 I had a similar issue with a listbox. I scabbed my solution from JohnBigBooty HERE. Below is my version of johnbigbooty's listbox.


1699547014327.png


1699547035951.png


I made it so only one form was open, not both.
HTH
Good luck with your project.
 
Use the listbox after update event to run an update query
If the bound field is called Id and the Boolean field is B. it could look similar to this
The Boolean field value will toggle True/False as the row is clicked

Code:
Private Sub ListBox_AfterUpdate()

CurrentDb.Execute "UPDATE TABLE1 Set B=Not B WHERE Id = " & Me.ListBox & ";"
Me.ListBox.Requery
End Sub
 
Good morning,
I apologize for the late reply..
thanks everyone, I tried the advice of isladogs unfortunately but gave a Runtime Error 3075: Syntax Error (missing operator) in query expression ID
my Table name is"TabScarico" listbox is "lista" and the Boolean fiels is "scaricato"
I appreciate your help and thank you

Samy
 
Good morning,
I apologize for the late reply..
thanks everyone, I tried the advice of isladogs unfortunately but gave a Runtime Error 3075: Syntax Error (missing operator) in query expression ID
my Table name is"TabScarico" listbox is "lista" and the Boolean fiels is "scaricato"
I appreciate your help and thank you

Samy
And you can't post what you tried to use? :(
 
@Gasman
Thanks for the reply..

Thats what I tried to use

Use the listbox after update event to run an update query
If the bound field is called Id and the Boolean field is B. it could look similar to this
The Boolean field value will toggle True/False as the row is clicked

Code:
Private Sub ListBox_AfterUpdate()

CurrentDb.Execute "UPDATE TABLE1 Set B=Not B WHERE Id = " & Me.ListBox & ";"
Me.ListBox.Requery
End Sub
 
Show your exact code, what @isladogs wrote should work unless the listbox was not numeric.
 

Users who are viewing this thread

Back
Top Bottom