W
Walter Levine
In an Access project (SQL Server) I am adding a new record to the table
using storedprocedures;
Application.CurrentProject.AccessConnection.Insert_Client_Record <parm
list>
Now I need the new record id: (only the last one works, but no triggers on
the table)
' strSQL = "SELECT SCOPE_IDENTITY() AS [SCOPE_IDENTITY] "
'strSQL = "select max(clientid) from tbl_Clients"
strSQL = "SELECT @@IDENTITY"
Set rs1 = New ADODB.Recordset
rs1.Open strSQL, Application.CurrentProject.Connection, adOpenKeyset,
adLockReadOnly
NewClientRecId = rs1.Fields(0).Value
rs1.Close
Set rs1 = Nothing
now add three more table inserts
Application.CurrentProject.AccessConnection.Insert_Status_Record
NewClientRecId, TempClient.Status (TempClient is a UDF)
Application.CurrentProject.AccessConnection.Insert_SW_Record
NewClientRecId, CLng(TempClient.sw)
Application.CurrentProject.AccessConnection.Insert_CheckList_Record
NewClientRecId
At this point, everything is ok, data is correctly added.
My problem is that now I need to sync up the form to display the new record
with the related table records
This is code from the combobox wizard, but it doesn't work. (no surprise,
it's DAO)
Dim rst As ADODB.Recordset
Set rst = Me.RecordsetClone
rst.Find "[CLIENTID] = " & str(NewClientRecId)
If Not rst.EOF Then
Me.Bookmark = rst.Bookmark
End If
rst.Close
Set rst = Nothing
How can I sync up the form with the new recrord?
When I was using DoCmd.GoRecord,,,acNewRecord,it worked automatically
Thanks for any input
Walter
using storedprocedures;
Application.CurrentProject.AccessConnection.Insert_Client_Record <parm
list>
Now I need the new record id: (only the last one works, but no triggers on
the table)
' strSQL = "SELECT SCOPE_IDENTITY() AS [SCOPE_IDENTITY] "
'strSQL = "select max(clientid) from tbl_Clients"
strSQL = "SELECT @@IDENTITY"
Set rs1 = New ADODB.Recordset
rs1.Open strSQL, Application.CurrentProject.Connection, adOpenKeyset,
adLockReadOnly
NewClientRecId = rs1.Fields(0).Value
rs1.Close
Set rs1 = Nothing
now add three more table inserts
Application.CurrentProject.AccessConnection.Insert_Status_Record
NewClientRecId, TempClient.Status (TempClient is a UDF)
Application.CurrentProject.AccessConnection.Insert_SW_Record
NewClientRecId, CLng(TempClient.sw)
Application.CurrentProject.AccessConnection.Insert_CheckList_Record
NewClientRecId
At this point, everything is ok, data is correctly added.
My problem is that now I need to sync up the form to display the new record
with the related table records
This is code from the combobox wizard, but it doesn't work. (no surprise,
it's DAO)
Dim rst As ADODB.Recordset
Set rst = Me.RecordsetClone
rst.Find "[CLIENTID] = " & str(NewClientRecId)
If Not rst.EOF Then
Me.Bookmark = rst.Bookmark
End If
rst.Close
Set rst = Nothing
How can I sync up the form with the new recrord?
When I was using DoCmd.GoRecord,,,acNewRecord,it worked automatically
Thanks for any input
Walter