teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

5

推敲

2020/07/10 07:23

投稿

sazi
sazi

スコア25430

answer CHANGED
@@ -3,7 +3,7 @@
3
3
  ```VBA
4
4
  If Me.txt日付 <> "" Then
5
5
  ' WhereString = WhereString & [分からない部分]
6
- WhereString = WhereString & " and 日付 >= #" & Me.txt日付 & "#" & " and and 日付 < #" & Me.txt日付 & "# + 1"
6
+ WhereString = WhereString & " and 日付 >= #" & Me.txt日付 & "#" & " and 日付 < #" & Me.txt日付 & "# + 1"
7
7
  End If
8
8
  ```
9
9
  若干性能は落ちると思いますが、文字型で揃えると以下になります。

4

追記

2020/07/10 07:23

投稿

sazi
sazi

スコア25430

answer CHANGED
@@ -1,10 +1,14 @@
1
1
  Me.txt日付の値は文字列ですから、日付型/時刻項目に対しての条件とする場合には、日付型に変換する必要があります。
2
2
  `#`で括ると日付/時刻型として認識されます。
3
3
  ```VBA
4
- If Me.txt日付 <> "" Then
4
+ If Me.txt日付 <> "" Then
5
- ' WhereString = WhereString & [分からない部分]
5
+ ' WhereString = WhereString & [分からない部分]
6
- WhereString = WhereString & " and 日付 >= #" & Me.txt日付 & "#" & " and and 日付 < #" & Me.txt日付 & "# + 1"
6
+ WhereString = WhereString & " and 日付 >= #" & Me.txt日付 & "#" & " and and 日付 < #" & Me.txt日付 & "# + 1"
7
-
8
- End If
7
+ End If
9
-
8
+ ```
9
+ 若干性能は落ちると思いますが、文字型で揃えると以下になります。
10
+ ```VBA
11
+ If Me.txt日付 <> "" Then
12
+ WhereString = WhereString & " and Format(日付,'yyyy/mm/dd') = '" & Me.txt日付 & "'"
13
+ End If
10
14
  ```

3

推敲

2020/07/10 06:02

投稿

sazi
sazi

スコア25430

answer CHANGED
@@ -1,5 +1,5 @@
1
- Me.txt日付の値は文字列ですから、日付型項目に対しての条件とする場合には、日付型に変換する必要があります。
1
+ Me.txt日付の値は文字列ですから、日付型/時刻項目に対しての条件とする場合には、日付型に変換する必要があります。
2
- `#`で括ると日付型として認識されます。
2
+ `#`で括ると日付/時刻型として認識されます。
3
3
  ```VBA
4
4
  If Me.txt日付 <> "" Then
5
5
  ' WhereString = WhereString & [分からない部分]

2

訂正

2020/07/10 05:56

投稿

sazi
sazi

スコア25430

answer CHANGED
@@ -3,7 +3,7 @@
3
3
  ```VBA
4
4
  If Me.txt日付 <> "" Then
5
5
  ' WhereString = WhereString & [分からない部分]
6
- WhereString = WhereString & " and 日付 = #" & Me.txt日付 & "#"
6
+ WhereString = WhereString & " and 日付 >= #" & Me.txt日付 & "#" & " and and 日付 < #" & Me.txt日付 & "# + 1"
7
7
 
8
8
  End If
9
9
 

1

推敲

2020/07/10 05:55

投稿

sazi
sazi

スコア25430

answer CHANGED
@@ -1,4 +1,4 @@
1
- Me.txt日付の値は文字列ですから、日付型項目にしての条件とする場合には、日付型に変換する必要があります。
1
+ Me.txt日付の値は文字列ですから、日付型項目にしての条件とする場合には、日付型に変換する必要があります。
2
2
  `#`で括ると日付型として認識されます。
3
3
  ```VBA
4
4
  If Me.txt日付 <> "" Then