23/04/2017, 02:41
ozanakkaya
Merhaba,
1. Mesaja eklediğiniz örnek uygulamaya ekleyeceğiniz butonun tıklandığında olayına aşağıdaki kodu ekleyiniz.
Ayrıca, 2. mesaja eklediğiniz örnek kodun, uygulamanıza uyarlanmış hali aşağıdadır.
2. kodun kullanılması tavsiye olunur.
1. Mesaja eklediğiniz örnek uygulamaya ekleyeceğiniz butonun tıklandığında olayına aşağıdaki kodu ekleyiniz.
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO Tablo1 ( a1 ) SELECT a1 FROM Tablo1 WHERE (((Kimlik)=" & Me.Kimlik & "));"
DoCmd.RunSQL "INSERT INTO Tablo2 ( a1aa, ki ) SELECT Tablo2.a1aa, DMax('Kimlik','Tablo1') AS SonSayi FROM Tablo2 WHERE (((ki)=" & Me.Kimlik & "));"
DoCmd.SetWarnings True
Ayrıca, 2. mesaja eklediğiniz örnek kodun, uygulamanıza uyarlanmış hali aşağıdadır.
On Error GoTo Err_Handler
'Purpose: Duplicate the main form record and related records in the subform.
Dim strSql As String 'SQL statement.
Dim lngID As Long 'Primary key value of the new record.
'Save any edits first
If Me.Dirty Then
Me.Dirty = False
End If
'Make sure there is a record to duplicate.
If Me.NewRecord Then
MsgBox "Select the record to duplicate."
Else
'Duplicate the main record: add to form's clone.
With Me.RecordsetClone
.AddNew
!a1 = Me.a1
' !CustomerID = Me.CustomerID
' !EmployeeID = Me.EmployeeID
' !OrderDate = Date
'etc for other fields.
.Update
'Save the primary key value, to use as the foreign key for the related records.
.Bookmark = .LastModified
lngID = !Kimlik
'Duplicate the related records: append query.
If Me.[Tablo2_alt_formu].Form.RecordsetClone.RecordCount > 0 Then
strSql = "INSERT INTO [Tablo2] ( ki, a1aa) " & _
"SELECT " & lngID & " As NewID, a1aa " & _
"FROM [Tablo2] WHERE ki = " & Me.Kimlik & ";"
DBEngine(0)(0).Execute strSql, dbFailOnError
Else
MsgBox "Main record duplicated, but there were no related records."
End If
'Display the new duplicate.
Me.Bookmark = .LastModified
End With
End If
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, , "cmdDupe_Click"
Resume Exit_Handler
2. kodun kullanılması tavsiye olunur.