I created a small MySQL database for our club using Access 2021 via an ODBC connection, which also works well.
I manage the members using a simple form. If I now create a new member and the following member has the same data. Only the date of birth and first name are different. I just want to copy the current data set and I can't do it. Maybe someone has already solved this and can help me with a template.
Thank you and Merry Christmas!
I solved it like this and it works:
Private Sub cmdCopy_Click()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("qryMitglieder", dbOpenDynaset)
Dim strNeueMitNr As String
Dim strNachname As String
Dim strStrasse As String
Dim strOrt As String
strNeueMitNr = neueMitNr("tblMitglieder")
strNachname = Me.Nachname
strStrasse = Me.Strasse
strOrt = Me.Ort
With rs
.AddNew
!MitNr = strNeueMitNr
!Nachname = strNachname
!Strasse = strStrasse
!Ort = strOrt
.Update
.Requery
End With
rs.Close
Set rs = Nothing
'an update with the new copied DS
Me.Requery
'and then go to the last record and display
DoCmd.GoToRecord , , acLast
End Sub
I manage the members using a simple form. If I now create a new member and the following member has the same data. Only the date of birth and first name are different. I just want to copy the current data set and I can't do it. Maybe someone has already solved this and can help me with a template.
Thank you and Merry Christmas!
I solved it like this and it works:
Private Sub cmdCopy_Click()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("qryMitglieder", dbOpenDynaset)
Dim strNeueMitNr As String
Dim strNachname As String
Dim strStrasse As String
Dim strOrt As String
strNeueMitNr = neueMitNr("tblMitglieder")
strNachname = Me.Nachname
strStrasse = Me.Strasse
strOrt = Me.Ort
With rs
.AddNew
!MitNr = strNeueMitNr
!Nachname = strNachname
!Strasse = strStrasse
!Ort = strOrt
.Update
.Requery
End With
rs.Close
Set rs = Nothing
'an update with the new copied DS
Me.Requery
'and then go to the last record and display
DoCmd.GoToRecord , , acLast
End Sub
Last edited: