Hi Hari
Not sure if this helps. This is my VBA code. The date that comes out of Record 0 in Table [Act Update] is 18/06/2007. The Value for Right_Date then = 15/06/2007 - which is what I expected. When I open the Table and view the field "Referral Creation Date" in Table [New Referrals] after it has been updated by the code below the value that appears in the Field isn't 15/06/2007 as I expected but "00:01:48"
Dim cnnX As ADODB.Connection
Dim MyRecordSet As New ADODB.Recordset
Dim Extract_Date As Date
Dim Right_Date As Date
Set cnnX = CurrentProject.Connection
MyRecordSet.ActiveConnection = cnnX
MyRecordSet.Open "[Act Update]"
MyRecordSet.MoveFirst
Extract_Date = MyRecordSet.Fields(0).Value
Right_Date = DateAdd("d", -1, Extract_Date)
DayofWk = Weekday(Right_Date, 2)
If DayofWk = 7 Then
Right_Date = DateAdd("d", -2, Right_Date)
ElseIf DayofWk = 6 Then
Right_Date = DateAdd("d", -1, Right_Date)
End If
DoCmd.RunSQL "UPDATE [New Referrals] SET [New Referrals].[Referral Creation Date] =" & Right_Date
Thanks for your help!
John T
Enter your message below
Sign in or Join us (it's free).