Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying data in Listbox

Status
Not open for further replies.

KalEl33

Programmer
May 20, 2002
17
US
I'm having trouble with getting data from a listbox and placing it in a table. I am using an update-query to grab data from a listbox and place it in a table called tblData. The listbox gets its data from a select-query. If I set the listbox's default value to some number (e.g. =2), then the field in tblData will be filled with 2. However if I leave the listbox's default value blank and only have the row source reference the select-query, when viewing the form I can see the value in the listbox that I want to place in tblData, but the field in tblData is left blank (actually a null value is placed in the field).

Any ideas on what is going on here? My goal is to just place the value that I see in the listbox in tblData.

Thanks in advance for you help.

Sincerely,
Kal-El
 
Could you post your expression in the update query? Maybe you're not referencing the list box correctly. (don't mean to be condescending, but sometimes I make silly errors without realizing it)

Kelly
 
KellyK,

Hey thanks for the reply. Don't worry about sounding condensending, you're not, besides so much of programming finding out where we made that silly little mistake that caused the whole thing to crash.

I figured out a solution to my problem. I ditched the listbox and I created a combobox which grabs a value from a query. The query returns two values (the first is a unique identifier e.g. 987654321, and the second is the value I'm looking for). I changed the column widths to 0";1" to show only the value I wanted. I then created a text box which I can query using an update query to change a field in a table. On the form's 'OnCurrent' Event, I placed the following code:

Forms!frmMyFormName!cboMyCombo = 987654321
Forms!frmMyFormName!txtMyTextbox.DefaultValue = Forms!frmMyFormName!cboMyCombo.column(1)

This solved my problem and perhaps can help others. I'm sure there is a much simpler way to achieve this same objective.

Thanks again for you response.

Kal-El
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top