删除用户输入框并用昨天的日期替换(自动化过程)
问题描述:
我有以下代码,并被要求删除用户输入框并自动提取文件。一个问题是,如果当天是星期一,我们需要将星期五的日期拉入(而不是昨天)。我很抱歉是非常基本的,但我相信我需要用之类的东西来代替InputBox("Input Date")
- 但它不喜欢Day
或DD
。删除用户输入框并用昨天的日期替换(自动化过程)
任何想法? (并感谢您的耐心与我提前)
DoCmd.SetWarnings False
Dim InvDateStr As String
Dim InvDate As Date
Dim Directory_Sheets As String
Dim filename_sheets As String
Dim db As Database
Dim rst As DAO.Recordset
Dim startdate As Date
Dim EndDate As Date
'startdate = #9/23/2010#
'enddate = #1/12/2011#
'InvDate = startdate
'Do Until InvDate = enddate
InvDateStr = InputBox("Input Date")
If InvDateStr = "" Then
Exit Sub
End If
InvDate = CDate(InvDateStr)
Directory_Sheets = FilePath & "Inventory_Surveys\"
On Error Resume Next
' Pull Stores with Inventory
答
我只打算做的日期部分,就可以实现它:
InvDate = Date - 1 'Yesterday
Do While Weekday(InvDate, vbMonday) > 5 'Saturday or Sunday
InvDate = InvDate - 1
Loop
+0
Erik - 非常感谢你 - 工作。非常感激! – Erika
减用'使用DateAdd日(“d “,-1,inputDate)' –