code is not woking properly

johnlatona123

Innovator
Local time
Today, 11:55
Joined
Sep 20, 2011
Messages
85
h iall,

my code is corectly writing to the first table and set of fields correctly, now i want to add the ability to write to a second table with a different group of fields.

what am i doing wrong here? it all should be done on after update.

Private Sub Form_AfterUpdate()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String
Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
'
strSQL = "SELECT * FROM [Change Tracking]"
rst.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
With rst
rst.AddNew
![job changed] = [Job]
![qty changed] = [QTY]
![time changed] = Now()
![due date changed] = [Due Date]
![line changed] = [Line]
![when issued] = [Issued not Complete]
![DWC date] = [Discrete workstation check]
![when completed] = [complete]
![comments changed] = [comments]
![active user] = modglobals.loginname
rst.Update
End With
'
rst.Close: Set rst = Nothing
cnn.Close: Set cnn = Nothing

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String
Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
strSQL = "SELECT * FROM [production]"
rst.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
With rst
rst.AddNew
![Job #] = [Job]
![product name] = [IPN]
![job qty] = [QTY]
![date scheduled] = [Due Date]
![line (machine ran on)] = [Line]
rst.Update
End With
'
rst.Close: Set rst = Nothing
cnn.Close: Set cnn = Nothing

End Sub


please help!
 
Where is the error?

Have you steped through the code to find the error.
 
well there is no error lol

the first portion of the code writes to a table

the second portion of the code does not.
 
Not much to go on.

Try using a Msgbox to display the values you are attempting to write. It might help to point us in the right direction.
 

Users who are viewing this thread

Back
Top Bottom