Larry Brister
asked on
ListBox MS Access 2005
Not sure if this is do-able.
I have a listbox on my form that is populating correctly
I have a click event on the ListBox and am getting the value of column (1)
Private Sub lbvHoursSID_Click()
varHours = Me.lbvHoursSID.Column(1)
Me.lblMessage.Caption = varHours
blah...blah...blah...
Is there any way to set the value of column(5) on a different textbox update event?
Something like...
Me.lbvHoursSID.Column(5) = Me.txtHours
I have a listbox on my form that is populating correctly
I have a click event on the ListBox and am getting the value of column (1)
Private Sub lbvHoursSID_Click()
varHours = Me.lbvHoursSID.Column(1)
Me.lblMessage.Caption = varHours
blah...blah...blah...
Is there any way to set the value of column(5) on a different textbox update event?
Something like...
Me.lbvHoursSID.Column(5) = Me.txtHours
Not directly like that.
To change a column value, you'd have to change the rowsource query, or change the value in the table that the rowsource is drawn from.
What is your overall goal for this idea? Can you use a separate control to show this value instead of changing the column?
To change a column value, you'd have to change the rowsource query, or change the value in the table that the rowsource is drawn from.
What is your overall goal for this idea? Can you use a separate control to show this value instead of changing the column?
ASKER
Here's my goal.
I have a listbox that loads the type of hours based on customer.
I can't have a jillion hours data entry boxes all over the form.
So...I want to click on the hours type description (unique per customer) and then enter the hours in a single text box.
When I tab off of that textbox, I want to store the value BACK in the hours column in the listBox.
You can see my controls below...
I'ts looking like I may have to feed these various values BACK into my recordset?
The other columns aren't visible. The column I'm trying to set is the (5)
This is the SUB that sets the record set
This is my screen print
I have a listbox that loads the type of hours based on customer.
I can't have a jillion hours data entry boxes all over the form.
So...I want to click on the hours type description (unique per customer) and then enter the hours in a single text box.
When I tab off of that textbox, I want to store the value BACK in the hours column in the listBox.
You can see my controls below...
I'ts looking like I may have to feed these various values BACK into my recordset?
The other columns aren't visible. The column I'm trying to set is the (5)
This is the SUB that sets the record set
Private Sub loadSID()
Dim cmd As New ADODB.Command
cmd.ActiveConnection = Conn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "usp_HoursTrackingSIDGet"
Set Me.lbvHoursSID.Recordset = cmd.Execute()
End Sub
This is my screen print
Okay...
Its not clear how you are storing the data for the listbox, but I think the code behind the textbox (Exit Event perhaps) would be something along these lines:
Its not clear how you are storing the data for the listbox, but I think the code behind the textbox (Exit Event perhaps) would be something along these lines:
Dim strSQL as string
' Update your table
strSQL = "UPDATE YourListBoxTable SET Hours = " & me.txtHoursReg & " WHERE Definition = 'Hours - Regular' AND PersonID = " & Me.PersonID
CurrentDB.execute strSQL, dbFailOnError + dbSeeChanges
'Re-load the listbox
LoadSID
ASKER
mbizup
This has to stay client side.
There may be dozens of people updating hundreds of records for the same customer at the same time.
On the client side is there no way of making provate recordset variable and updating the record for a particular row and then rebinding the listbox to THAT recordset?
In .Net this isn't an issue...I'd just cache everything and feed it back into the dataset/datatable.
But these folks are still in MS Access and I have to deal with this.
This has to stay client side.
There may be dozens of people updating hundreds of records for the same customer at the same time.
On the client side is there no way of making provate recordset variable and updating the record for a particular row and then rebinding the listbox to THAT recordset?
In .Net this isn't an issue...I'd just cache everything and feed it back into the dataset/datatable.
But these folks are still in MS Access and I have to deal with this.
Okay try this from the exit or lost focus event of your text box:
dim rs as DAO.recordset
set rs = Me.lbvHoursSID.Recordset
rs.FindFirst "Definition = 'Hours - Regular'"
rs.Edit
rs!Hours = me.txtHoursReg
rs.update
Me.lbvHoursSID.Requery
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Capricorn1,
Sorry for the late get back.
Thanks
Sorry for the late get back.
Thanks
Column Count 5 ' the least number of columns you can have could be more
now you can use this
Me.txtHours = Me.lbvHoursSID.Column(5)
you can also specify the Column Widths