3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【ACCESS】テキストボックス未入力の場合は値取得時に注意

Last updated at Posted at 2018-08-29

備忘録として残します。

ACCESSのテキストボックスは未入力の場合、そのテキストボックスの値を参照するとNULLとなります。
当然、値が返ってくる場合は、入力した内容が値として参照できます。
ACCESSを普段から使用しているエンジニアであれば当然の話とは思いますが、Webエンジニアの私には衝撃でした。

もし、未入力の場合、から文字("")として値を取得する場合は「Nz関数」を使用しましょう。
Nz関数とは何ぞや?
「Null合体演算子」と同じような動きをしてくれるものみたいです。

'第1引数がNullであれば、第2引数を返す。
Nz(Me![テキストボックス], "")

Nz関数の仕様上、第1引数が文字列であれば第2引数を省略しても上記と同じように空文字を返すのですが、そもそもNullなのにどうやって型を判別してるのか不明。

以上です。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?