This is an odd one for me. I’ve programmed in VB for years and I’m making the transition to Access. The VB ListBox does not have columns like the Access one.
I have an Access form with no control source or record selector. There is a ListBox with 2 columns and a query that is the control source. The first column is First and Last Name and the second column is an integer value. The integer is from an auto-number field. The second column with the integer is bound.
When a user clicks on an item in the listbox I use the value from the bound column to do some DlookUps to fill some Labels. There is other stuff going on on the form but nothing else interacts with the ListBox until a Save button is clicked.
When the Save button is clicked data from other controls is written to a table. A value from the same bound column from the listbox is stored in the this table along with the data from the other controls.
Here’s the odd thing.
When the form loads and the first DlookUps happen I get an error because it is getting info from the unbound first column. Instead of doing the search on the integer from the bound second column, it uses the value from the first column. This causes a type mismatch and this only happens on start-up. All other Dlookups are fine after that.
Also, when I close the form, what ever was the first item clicked on in the list box, the integer value is written to the name field. If I just load the form and click a few times on the list box and then close, the next time I open it, the first name is gone and there is a number in it’s place.
John Smith – 46 becomes 46 – 46.
No where in code am I writing to that table. Also, all properties for the listbox (e.g. control source, bound column, etc) are set at design time. It seems to think that the first column is bound for the initial start-up and then it switches to the second column.
What the heck is going on!
I have an Access form with no control source or record selector. There is a ListBox with 2 columns and a query that is the control source. The first column is First and Last Name and the second column is an integer value. The integer is from an auto-number field. The second column with the integer is bound.
When a user clicks on an item in the listbox I use the value from the bound column to do some DlookUps to fill some Labels. There is other stuff going on on the form but nothing else interacts with the ListBox until a Save button is clicked.
When the Save button is clicked data from other controls is written to a table. A value from the same bound column from the listbox is stored in the this table along with the data from the other controls.
Here’s the odd thing.
When the form loads and the first DlookUps happen I get an error because it is getting info from the unbound first column. Instead of doing the search on the integer from the bound second column, it uses the value from the first column. This causes a type mismatch and this only happens on start-up. All other Dlookups are fine after that.
Also, when I close the form, what ever was the first item clicked on in the list box, the integer value is written to the name field. If I just load the form and click a few times on the list box and then close, the next time I open it, the first name is gone and there is a number in it’s place.
John Smith – 46 becomes 46 – 46.
No where in code am I writing to that table. Also, all properties for the listbox (e.g. control source, bound column, etc) are set at design time. It seems to think that the first column is bound for the initial start-up and then it switches to the second column.
What the heck is going on!