how do i find a record and the update it

AMH

New member
Local time
Today, 13:16
Joined
Jun 19, 2001
Messages
9
I have a form based on query based on a table called allocations. On the form there is a combo box for contract number. What i am trying to do is find the contract in the contracts table based on the contract number selected from the combo box and then update a field in the contract table with a value from the form. I am using the code below but i keep getting METHOD OR DATA MEMBER NOT FOUND. any help would be great ...

Dim rstadddelqty As ADODB.Recordset

Dim strCnn As String

On Error GoTo Err_cmdsavealloc_Click

Set rstadddelqty = New ADODB.Recordset
rstadddelqty.Open "Select * From Contract", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rstadddelqty.findfirst "[contractnumber]= " & Me![cbopurchase]
rstadddelqty.Fields("DeliveredQty") = Me.QuantityKilos
 
I would do something like this...

dim rst as Recordset
dim dbs as Database
dim strSql as String

set dbs = CurrentDB

strSql = SELECT DeliveredQTY FROM tblContract WHERE contractnumber = " & me.cbopurchase &";"

set rst = dbs.OpenRecordSet(strSql, dbOpenDynaset)

with rst
.Edit
!DeliveredQTY = Me.QuantityKilos
.Update
end with

set rst = nothing
set dbs = nothing

Alternatively you might place a breakpoint at the start of the code and this will help you find which line is causing the error.
HTH
Chris
 

Users who are viewing this thread

Back
Top Bottom