I am trying to create a procedure that will populate a table with dates. The code is listed below
When I run the procedure I get
Compile error:
Invalid outside procedure
and debug brings me to this line
SDate = "5/20/2006"
Can someone tell be what I am doing wrong and if this code will achieve my goal?
Newbie in search of knowledge
When I run the procedure I get
Compile error:
Invalid outside procedure
and debug brings me to this line
SDate = "5/20/2006"
Code:
Option Explicit
Dim SDate As Date
Dim EDate As Date
Dim sqlstr As String
SDate = "5/20/2006"
EDate = "6/30/2007"
Public Sub PayPeriods()
Do While (SDate < EDate)
sqlstr = "insert into tblPayPeriod (" & StartDate & ")" & "values (" & SDate & ")"
DoCmd.RunSQL sqlstr
SDate = DateAdd("d", 14, SDate)
Loop
End Sub
Can someone tell be what I am doing wrong and if this code will achieve my goal?
Newbie in search of knowledge