Ok, the following code checks to see if a record exists in the ORDER table, and if it doesn't it adds it to the table. It uses an ADO implementation. Now, the problem is, it takes a while before the ORDER table is updated with the new entry. I was thinking that the table would be updated immediately with the .Update command, but this doesn't seem to be the case.
Does anyone know how to add a new record to the table followed by the table updating itself immediately?
Private Sub Command55_Click()
On Error GoTo command55_click_err
Dim criteria(1) As Variant
Dim stdocname As String
Dim curconn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim curdb As Database
Set curdb = CurrentDb
Set curconn = New ADODB.Connection
criteria(0) = Forms!start!
Does anyone know how to add a new record to the table followed by the table updating itself immediately?
Private Sub Command55_Click()
On Error GoTo command55_click_err
Dim criteria(1) As Variant
Dim stdocname As String
Dim curconn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim curdb As Database
Set curdb = CurrentDb
Set curconn = New ADODB.Connection
criteria(0) = Forms!start!
NUMBER said:criteria(1) = Forms!start![ITEM NUMBER]
With curconn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source= " & curdb.Name
.Open
End With
Set rst = New ADODB.Recordset
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open "ORDER", curconn, , , adCmdTableDirect
rst.MoveFirst
rst.Index = "PrimaryKey"
rst.Seek criteria
If rst.EOF Then
With rst
'add new record
.AddNew
!NUMBER said:= criteria(0)
![ITEM NUMBER] = criteria(1)
.Update 'at this point shouldn't the table update
End With
End If
rst.Close
'stdocname = "Order Checklist Form"
'DoCmd.OpenForm stdocname
command55_click_exit:
Exit Sub
command55_click_err:
MsgBox Err.Description
Resume command55_click_exit
End Sub
Thanks in advance.