MS Access 表單日期/時間輸入問題 (MS Access Forms Date/Time Entry Trouble)


問題描述

MS Access 表單日期/時間輸入問題 (MS Access Forms Date/Time Entry Trouble)

所以我有幾個表,我想在它們的日期/時間字段上進行過濾。這是我正在試驗的表單控件的快照。

Snapshot of form

這份報告可能最終會在每月一次,因此過濾器“Between Forms!Sorting!OldestDate and Forms!Sorting!NewestDate” 通常會正常工作。然而,有時只在一天內運行它很有用,如圖所示,在這種情況下,我需要過濾器計算出“Between #M/D/YYYY 0:00:00# and #M/D” /YYYY 23:59:59#”。然而,在控件上設置格式以實際記錄時間和日期並沒有奏效。

我想,首先,也許時間沒有顯示,因為我的文本框是太小了,所以我嘗試添加底部文本框。快照中的顯示是我想要的,但是,如果我在文本框中單擊,日期就會消失,只顯示時間。在我進入並手動添加時間之前,它也根本不顯示任何時間。

有沒有辦法強制顯示短日期和長時間?或者有沒有辦法,比如說,將 NewestDate 的默認時間值設置為 23:59:59?

目前唯一的“解決方案”是 我可能有 CVDate(CDbl(Forms!Sorting!NewestDate)+0.99999) 在我的 WHERE 子句中出現多次,這將使事情更難跟踪或發現錯誤。

我有 vba 經驗,但我從未嘗試使用它來屏蔽/編輯傳遞給查詢的表單參數。我正在通過 MS Office Professional Plus 2019 使用 Access。


參考解法

方法 1:

First, in your query, specify as parameters:

[Forms]![Sorting]![OldestDate] DateTime,
[Forms]![Sorting]![NewestDate] DateTime;

Then you can filter on:

[YourDateField] >= [Forms]![Sorting]![OldestDate] And [YourDateField] < DateAdd("d", [Forms]![Sorting]![NewestDate])

If [YourDateField] is text, change that to DateTime. If that is not possible (it should be), use:

DateValue([YourDateField])

(by L KadueGustav)

參考文件

  1. MS Access Forms Date/Time Entry Trouble (CC BY‑SA 2.5/3.0/4.0)

#datetime-format #ms-access-forms #formatting #ms-access






相關問題

給定一個 DateTime 對象,如何獲取字符串格式的 ISO 8601 日期? (Given a DateTime object, how do I get an ISO 8601 date in string format?)

Праграма WPF наладжвае кароткую дату пры выкарыстанні stringformat={}{0:d} (WPF application customize shortdate when using stringformat={}{0:d})

使用 java.time.DateTimeFormatter 格式化 java Date,包括時間偏移 (Formating java Date with java.time.DateTimeFormatter including time offset)

# 如何使用 DateTime 類(處理轉換、格式、差異和時區) (# How to use the DateTime class (Dealing with Conversions, Formatting, Diffs, and Time zones))

從一種時間格式轉換為另一種時間格式 (Converting from one time format to the other)

如何將python中的數據框列對象轉換為日期時間格式 (How to convert a dataframe column object in python to date time format)

BeautifulSoup:如何以 datwtime 格式獲取 youtube 視頻的發布日期時間? (BeautifulSoup: How to get publish datetime of a youtube video in datwtime format?)

如何在 C# 中轉換 dateTime 格式? (How do I convert dateTime format in C#?)

在 SQL 中的時間範圍之間獲取記錄的替代方法(計算財政年度) (Alternative ways to get records between a time frame in SQL (calculate fiscal year))

Elasticsearch 自定義日期時間格式,包括。序數 (Elasticsearch custom date time format incl. ordinal numbers)

我有一個 int 格式的日期 DDMMYYYY,我怎樣才能分隔日月年 (I have a date in int format DDMMYYYY, how can I separate day and month and year)

Intl.DateTimeFormat 中 dayPeriod 的參考 (Reference for dayPeriod in Intl.DateTimeFormat)







留言討論