How to find a record and then update it

AMH

New member
Local time
Today, 07:34
Joined
Jun 19, 2001
Messages
9
I have a form containing a combo box which is a contract number. What i am trying to do is find a record in the contracts table based on the contract number selected from the combo box and then update the record in the contract table with a value from the current form. The current form is not based on the contracts table it is based on a query on a table called allocaions. Any help would be gratefully received... Thanks..
 
dim db as database
dim rst as recordset

set db=currentdb
set rst=db.openrecordset("allocations")

rst.findfirst "[ContractNum]=" & Me!cboContract

rst!fldtoUpdate=Me!fldWithUpdateValue
 
this code seemed to do the trick uses find intstead of find first

Thanks for the help !!

Dim cnn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strPurContract As String
Dim strSalContract As String
Dim intDelQty As Long

On Error GoTo Err_cmdsavealloc_Click
'
' set connection and recordset
'
Set cnn = CurrentProject.Connection
rst.Open "Contract", cnn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
'
' Set string to combo box value for purchases
'
strPurContract = Me!cbopurchase
'
' now do a find in contracts table for purchase contract and update del qty
'
rst.Find "[ContractNumber]='" & strPurContract & "'", 0, adSearchForward
If IsNull(rst.Fields("DeliveredQty")) Then
rst.Fields("DeliveredQty") = 0
End If
rst.Fields("DeliveredQty") = rst.Fields("DeliveredQty") + Me.QuantityKilos
rst.Update
rst.Close
 

Users who are viewing this thread

Back
Top Bottom