删除用户输入框并替换为昨天的日期(自动化过程)

时间:2017-10-18 20:01:09

标签: ms-access datepicker

我有以下代码,并被要求删除用户输入框并自动拉入文件。一个问题是如果当天是星期一,我们需要周五的日期(不是昨天)。我很抱歉非常基本,但我认为我需要用InputBox("Input Date")替换DateAdd(Day, DateDiff(Day, 1, GETDATE()), 0) - 但它不喜欢DayDD

有什么想法吗? (并感谢您提前耐心等待我)

 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

1 个答案:

答案 0 :(得分:1)

我只会去做日期部分,你可以实现它:

InvDate = Date - 1 'Yesterday
Do While Weekday(InvDate, vbMonday) > 5 'Saturday or Sunday
   InvDate = InvDate - 1
Loop