0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Accessでコンボボックスに勝手な値を入力されないように制御

Last updated at Posted at 2022-12-16

概要

こういうコンボボックスがある…
image.png
image.png

↓ こんなふううに、されないようにしたい。(規定の選択肢以外はダメよ)
image.png

やり方

まず前提として、コンボボックスには制御するプロパティが無い。

イベントで制御が必要。

キー入力時

image.png

Private Sub cmb_tester_KeyPress(KeyAscii As Integer)
    KeyAscii = 0
End Sub

キークリック時

『キー入力時』だけだと全角入力ができてしまう。
なので『キークリック時』でも制御が必要。

image.png

Private Sub cmb_tester_KeyDown(KeyCode As Integer, Shift As Integer)
    KeyCode = 0
End Sub

『入力チェック』と『値リストの編集の許可』

こうなるように。
image.png

参考サイトさん

バージョン

Windows 10 Pro 21H2 OSビルド 19045.2311
Microsoft Access for Microsoft 365 MSO (バージョン 2211 ビルド 16.0.15831.20098) 32 ビット

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?