J
Jonathan Stratford
Hi,
I'm trying to make a button which, when clicked, will add
all the dates of all weekends in the current year to a
table. This is the code i use, but it says i'm trying to
add too many records after it tries to add the second.
Can anyone give me any help on this?
Thanks in advance,
Jonathan Stratford
Dim con As Connection
Dim strSQL As String
Dim rs As Recordset
DoCmd.Close acForm, Me.Name, acSaveYes
Set con = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.Recordset")
rs.Open "TSpecialDays", con, adOpenDynamic,
adLockBatchOptimistic
For newDate = CDate("1/1/" & Year(Now())) To CDate
("31/12/" & Year(Now()))
If WeekdayName(Weekday(newDate)) = "Sunday" Or WeekdayName
(Weekday(newDate)) = "Saturday" Then
MsgBox newDate & " " & WeekdayName(Weekday(newDate))
rs.AddNew "Special Day Date", CStr(newDate)
rs.Update
End If
Next
rs.Close
Set rs = Nothing
Set con = Nothing
I'm trying to make a button which, when clicked, will add
all the dates of all weekends in the current year to a
table. This is the code i use, but it says i'm trying to
add too many records after it tries to add the second.
Can anyone give me any help on this?
Thanks in advance,
Jonathan Stratford
Dim con As Connection
Dim strSQL As String
Dim rs As Recordset
DoCmd.Close acForm, Me.Name, acSaveYes
Set con = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.Recordset")
rs.Open "TSpecialDays", con, adOpenDynamic,
adLockBatchOptimistic
For newDate = CDate("1/1/" & Year(Now())) To CDate
("31/12/" & Year(Now()))
If WeekdayName(Weekday(newDate)) = "Sunday" Or WeekdayName
(Weekday(newDate)) = "Saturday" Then
MsgBox newDate & " " & WeekdayName(Weekday(newDate))
rs.AddNew "Special Day Date", CStr(newDate)
rs.Update
End If
Next
rs.Close
Set rs = Nothing
Set con = Nothing