Dachande11
Registered User.
- Local time
- Today, 03:59
- Joined
- May 1, 2001
- Messages
- 41
Hi, I have a piece of code that is supposed to check a table for the last date in it and if it is not yesterdays (or fridays date if opening on a monday) then it is supposed to import a text file. The problem is it is not recognising the last date and so just keeps importing each time.
Here is the code to check dates, can anybody help?
Private Sub Form_Load()
DayNum = "w"
If DatePart(DayNum, Date) = 2 Then
Lastdate = Date - 3
Else
Lastdate = Date - 1
End If
'Confirms import data in CommDB for last commissionable date
GotData = DLast("[Transaction_Date]", "Slowstk")
'Checks to see if import routine is needed
If GotData = Lastdate Then
DoCmd.Close
DoCmd.OpenForm "Main Menu", acNormal, "", "", acReadOnly, acNormal
Else
'Runs import routine
DoCmd.Hourglass True
DoCmd.SetWarnings False
DoCmd.TransferText acImportDelim, "Slowstk Import Specification", "Slowstk", "K:\3ex\comm\Slowstk.txt", False, "", 850
DoCmd.SetWarnings True
DoCmd.Hourglass False
DoCmd.Close
DoCmd.OpenForm "Main Menu", acNormal, "", "", acReadOnly, acNormal
End If
Exit_DecisionBox:
Exit Sub
End Sub
Here is the code to check dates, can anybody help?
Private Sub Form_Load()
DayNum = "w"
If DatePart(DayNum, Date) = 2 Then
Lastdate = Date - 3
Else
Lastdate = Date - 1
End If
'Confirms import data in CommDB for last commissionable date
GotData = DLast("[Transaction_Date]", "Slowstk")
'Checks to see if import routine is needed
If GotData = Lastdate Then
DoCmd.Close
DoCmd.OpenForm "Main Menu", acNormal, "", "", acReadOnly, acNormal
Else
'Runs import routine
DoCmd.Hourglass True
DoCmd.SetWarnings False
DoCmd.TransferText acImportDelim, "Slowstk Import Specification", "Slowstk", "K:\3ex\comm\Slowstk.txt", False, "", 850
DoCmd.SetWarnings True
DoCmd.Hourglass False
DoCmd.Close
DoCmd.OpenForm "Main Menu", acNormal, "", "", acReadOnly, acNormal
End If
Exit_DecisionBox:
Exit Sub
End Sub