Full Version: Data in only one textbox
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
mattbrem
If I have a form with multiple textboxes (unbound) is there an easy way to check that the user only entered data in a single text box before clicking a button?
Peter46
Depends on what you class as easy.

You create a procedure which checks that a max of one box contains data and you run that procedure in the afterupdate event procedure of each textbox.

For example(assumes you are expecting text values:

sub checkmax1()
Dim Kount
If nz(me.textbox1,"")>"" then Kount=kount+1
If nz(me.textbox2,"")>"" then Kount=kount+1
If nz(me.textbox3,"")>"" then Kount=kount+1
if Kount >1 then msgbox "Too many boxes filled"
end sub
mattbrem
That was easy enough, thanks!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.