K
Kevin
Option Compare Database
Option Explicit
Sub adddate()
Dim dtestart As Date, dteend As Date, dterun As Date, intcount As Integer, intperiods As Integer
Dim Period As Integer, vYear As Integer, vName As String
Dim strnum As String
intcount = 1
intperiods = 13
dtestart = #4/1/2004# 'US date format
vName = "BOPSWSOR"
vYear = 2004
If 13 / 4 > Int(13 / 4) Then
strnum = Int(13 / 4) + 1
Else
strnum = Int(13 / 4)
End If
Do While intcount <= intperiods
dteend = DateAdd("d", 28, dtestart)
dterun = DateAdd("d", 2, dteend)
If intperiods = 13 Then
Period = intcount
Else
Period = intcount / 4
End If
DoCmd.RunSQL "insert into kevfeeder ([Name], [Rundate], [Year], [Period], [startdate], [enddate]) values (vName, dterun, vYear, Period, dtestart, dteend)"
intcount = intcount + 1
dtestart = DateAdd("d", -1, dteend)
Loop
End Sub
I am being prompted to enter values for the variables although they are declared and assigned. I am a newbie. Sorry if this is a bit basic
Option Explicit
Sub adddate()
Dim dtestart As Date, dteend As Date, dterun As Date, intcount As Integer, intperiods As Integer
Dim Period As Integer, vYear As Integer, vName As String
Dim strnum As String
intcount = 1
intperiods = 13
dtestart = #4/1/2004# 'US date format
vName = "BOPSWSOR"
vYear = 2004
If 13 / 4 > Int(13 / 4) Then
strnum = Int(13 / 4) + 1
Else
strnum = Int(13 / 4)
End If
Do While intcount <= intperiods
dteend = DateAdd("d", 28, dtestart)
dterun = DateAdd("d", 2, dteend)
If intperiods = 13 Then
Period = intcount
Else
Period = intcount / 4
End If
DoCmd.RunSQL "insert into kevfeeder ([Name], [Rundate], [Year], [Period], [startdate], [enddate]) values (vName, dterun, vYear, Period, dtestart, dteend)"
intcount = intcount + 1
dtestart = DateAdd("d", -1, dteend)
Loop
End Sub
I am being prompted to enter values for the variables although they are declared and assigned. I am a newbie. Sorry if this is a bit basic