M
MJ
My challenge is to pass a changing date variable from the code to an Update
Query.
I already have a variable declared (DateComplete) and in use within the code
that contains the value I want to pass, but just not sure how to make it
happen using the DoCmd.OpenQuery structure.
Below is some of the code to help scope this out:
======================
Private Sub CmdImport_Click() 'Import Files -- using the dates input on the
form
On Error GoTo Err_CmdImport_Click
Dim dbMyDB As Database
Dim EndDate As Date
Dim PrevDate As Date
Dim StartDate As Date
Dim d As Integer
Dim DaystoImport As Integer
Dim DateComplete As String
Dim strEnd As String
Dim strStart As String
Dim strStart2 As String
Set dbMyDB = CurrentDb
DoCmd.SetWarnings False
PrevDate = DLookup("When", "LastDateDone")
StartDate = PrevDate + 1
EndDate = Me.EndDate
If (EndDate < StartDate) Then
...
Else
DaystoImport = (EndDate - StartDate) + 1
For d = 1 To DaystoImport
DateComplete = Format(DateAdd("d", (d - 1), StartDate),
"mm/dd/yyyy")
...
DoCmd.OpenQuery "qry: Step3_Completed"
...
Next d
End If
...
End Sub
=================
Is there a simple/easy way to pass the value of variable "DateComplete" to
"qry: Step3_Completed" so that my users do not have to enter a date everytime
the loop is processed?
Thanks in advance for your assistance with this.
MJ
Query.
I already have a variable declared (DateComplete) and in use within the code
that contains the value I want to pass, but just not sure how to make it
happen using the DoCmd.OpenQuery structure.
Below is some of the code to help scope this out:
======================
Private Sub CmdImport_Click() 'Import Files -- using the dates input on the
form
On Error GoTo Err_CmdImport_Click
Dim dbMyDB As Database
Dim EndDate As Date
Dim PrevDate As Date
Dim StartDate As Date
Dim d As Integer
Dim DaystoImport As Integer
Dim DateComplete As String
Dim strEnd As String
Dim strStart As String
Dim strStart2 As String
Set dbMyDB = CurrentDb
DoCmd.SetWarnings False
PrevDate = DLookup("When", "LastDateDone")
StartDate = PrevDate + 1
EndDate = Me.EndDate
If (EndDate < StartDate) Then
...
Else
DaystoImport = (EndDate - StartDate) + 1
For d = 1 To DaystoImport
DateComplete = Format(DateAdd("d", (d - 1), StartDate),
"mm/dd/yyyy")
...
DoCmd.OpenQuery "qry: Step3_Completed"
...
Next d
End If
...
End Sub
=================
Is there a simple/easy way to pass the value of variable "DateComplete" to
"qry: Step3_Completed" so that my users do not have to enter a date everytime
the loop is processed?
Thanks in advance for your assistance with this.
MJ