Please help me with this problem.

WhizzkidWallace

Registered User.
Local time
Today, 21:49
Joined
Jan 10, 2005
Messages
49
Hi,

I have a problem updating records with data from a form. Here is the scenario. I have two fields on the form, which create two variables 'intContractNumber' and 'curRetentionHeld'. When I click my Accept button, I want to locate the record in a recordset and write the new data. Here is the code

Dim strSQL As String
Dim conTemp As ADODB.Connection
Set conTemp = CurrentProject.Connection
Dim rsTemp As New ADODB.Recordset
rsTemp.ActiveConnection = conTemp
strSQL = "SELECT tblAccountsSalesLedgerRetentions.ContractNumber, tblAccountsSalesLedgerRetentions.RetentionHeld FROM tblAccountsSalesLedgerRetentions WHERE (((tblAccountsSalesLedgerRetentions.ContractNumber)=" & Str(intContractNumber) & "))"
rsTemp.Open strSQL
If (rsTemp.EOF) Then
MsgBox "Record NOT found"
Else
rsTemp![RetentionHeld] = curRetention
End If
rsTemp.Close
Set rsTemp = Nothing
Set conTemp = Nothing

It results in an error when the ' rsTemp![RetentionHeld]...line runs.

Thanks
 
only know vague DAO stuff but...

do you not need .edit and .update cmd

steve
 
Thanks, but I have sorted it....I had opended the recordset with default locking i.e READONLY...Just had to add adlockoptimistic to recordset line.
 
Your variable name that you created, "curRententionHeld", does not match the variable in the line, "rsTemp![RetentionHeld] = curRetention

Fix that and see what happens.
 

Users who are viewing this thread

Back
Top Bottom