Storing values back into the tables

  • Thread starter Thread starter Nexus
  • Start date Start date
If it is a bound form(i.e.. recorsource is bound to a table/query) and if
it's a query that the query designed so that it can update the tables then
all you have to do is open the form in design. Double-click the textbox to
open the properties window. Set the Control Source to a field name from the
drop-down box. If the form is unbound you will either need to use code or
run and update query. Hope this helps.
 
But what if the textbox is already bound using a DLookUp??
Here are the codes for that segment, if you could help me
take a look. Thanks!

Private Sub cmdTransact_Click()
Dim intCurrentInvLevel As Integer
Dim strToolID As String

Me.Requery
strToolID = lstGetToolDetail
intCurrentInvLevel = InventoryLevel
Select Case lstTransactionType
Case "Tool Issue"
TransacIR
InventoryLevel = intCurrentInvLevel -
txtTransactionQty
Case "Tool Return"
TransacIR
InventoryLevel = intCurrentInvLevel +
txtTransactionQty
Case "Lost Tool"
TransacLD
InventoryLevel = intCurrentInvLevel -
txtTransactionQty
Case "Damaged Tool"
TransacLD
InventoryLevel = intCurrentInvLevel -
txtTransactionQty
Case "Tool Returned After Rework"
TransacRW
InventoryLevel = intCurrentInvLevel +
txtTransactionQty
Case "Receipt of Purchased Tool"
TransacPR
InventoryLevel = intCurrentInvLevel +
txtTransactionQty
End Select

Forms!frmViewEditTools!txtLastUpdate = txtTransactionDate
Forms!frmViewEditTools!txtLastTransacType =
lstTransactionType
Forms!frmViewEditTools!txtLastEmployeeName =
cmbEmployeeID.Column(1)
Me.Requery
End Sub
 
I don't think you can have a bound textbox if it is bound to the table then
just move to a new record
If it is an unbound field that you have populated using DLookup you will
need to use an update query or code
 
Newbie is correct....using DLookup in the control source of a textbox means
that the textbox is unbound and cannot directly/automatically store its data
in a field in the form's recordsource.

(One should ask -- why would you need to store this value in a table if it's
already available in another table, as evidenced by the ability to use
DLookup to find its value based on something in the currrent form/table?)

Another way to accomplish this storage is to not use DLookup in the
textbox's control source. Instead, bind that textbox to the desired field,
and then use code on the AfterUpdate event of the control that provides the
"criterion" value for DLookup expression and write the value into that
textbox. But again...consider my question in the second paragraph.
 
Ken said:
(One should ask -- why would you need to store this value in a table if it's
already available in another table, as evidenced by the ability to use
DLookup to find its value based on something in the currrent form/table?)

Well put, Ken. This is a key point here!
 
Back
Top