Solved How to use a hidden ListBox Column to open records

mamradzelvy

Member
Local time
Today, 08:30
Joined
Apr 14, 2020
Messages
145
Hi,
I've been going on about this clickable listbox for a while now and I'm sorry for that, however I'm now attempting to hide the column i use to open records (the ID column within records).
So i got a table with 9 columns, but in my ListBox RowSource i have the ID field on 8th position in the SQL SELECT.
In the ListBox properties i set the ColumnCount to 5 to hide stuff i wish not to display, but it made my code which opens a new form on a selected record unusable once more.

How do i hide the Columns within my ListBox while still being able to use them to open other forms?

This is the RowSource for my ListBox:
Code:
Me!lstInventory.RowSource = "SELECT TabKlient, TabOsoba, TabItem, TabQty, TabNote, TabAddedBy, TabDate, TabStatus, ID FROM Tabule1 WHERE TabStatus LIKE '0';"

This is the code to open the second form:
Code:
DoCmd.OpenForm "formEditTabule", , , "ID LIKE '" & Me.lstInventory.Column(8) & "'"
 
I was unsure whether to post this into the VBA section or here, so please forgive me if I was wrong.
 
Is the ID numeric?
"ID = " & Me.lstInventory.Column(8)
Or if you bind the column you want you can use the value property of the listbox instead of worrying about column
"ID = " & me.lstInventory
 
I tend to ALWAYS have my key field as the first in any listbox/combo and that is the one bound and always hidden.?
Then it does not matter what I show.?
 
I tend to ALWAYS have my key field as the first in any listbox/combo and that is the one bound and always hidden.?
Then it does not matter what I show.?

thank you both!

Thanks to Gasman's comment i tried putting the ID collumn first in the rowsource SQL and in the properties of the listbox enabled one more row but put the first row's length to 0cm which did the trick
 

Users who are viewing this thread

Back
Top Bottom