Gee I feel thick now.
Here is the code anyway.
Private Sub cmdFinished_Click()
'Change the focus back to the main form and hide the data entry form
Forms!frmDrawingscomplete!cboCust.SetFocus
Me.Visible = False
'Make visible and Requery the viewing forms
Forms!frmDrawingscomplete!fsubDrawRev1.Form.Requery
Forms!frmDrawingscomplete!fsubDrawRev1.Form.Visible = True
Forms!frmDrawingscomplete!fsubDraw.Form.Requery
Forms!frmDrawingscomplete!fsubDraw.Form.Visible = True
Dim sql1 As String
Dim str As String
Dim strSQLRestore As String
Dim cnn As Connection
Dim rstDrawings As ADODB.Recordset
Dim strsql1 As String
Dim MyCustPartid As Variant
Dim MyNewCustPartid As String
Dim blnRecordAddred As Boolean
On Error GoTo Err_cmdSave_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'Open a connection
Set cnn = New ADODB.Connection
str = "Provider=SQLOLEDB;Data Source=SBS;" & _
"Initial Catalog=DrawingsDemoSQL;User Id=SQLACCESS;Password=caragh*2004;"
cnn.Open str
'Open table tblDrawRev to update .
Set rstDrawings = New ADODB.Recordset
strsql1 = "tblDrawings"
rstDrawings.Open strsql, cnn, adOpenKeyset, adLockOptimistic, adCmdTable
rstDrawings.MoveLast
rstDrawings!CustPartid = MyCustPartid
rstDrawings.Update
'Close the recordset
rstDrawings.Close
Set rstDrawings = Nothing
'Close the connection
cnn.Close
Set cnn = Nothing
Exit Sub
ErrorHandler:
'Clean Up
If Not rstCustPart Is Nothing Then
If rstCustPart.State = adStateOpen Then rstCustPart.Close
End If
Set rstDraw = Nothing
If Not cnn Is Nothing Then
If cnn.State = adStateOpen Then cnn.Close
End If
Set cnn = Nothing
If Err <> 0 Then
MsgBox Err.Source & "--->" & Err.Description, , "Error"
End If
Exit_cmdSave_Click:
Exit Sub
Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click
End Sub