mattbrem
Feb 10 2009, 08:40 AM
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
Feb 10 2009, 08:47 AM
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
Feb 10 2009, 09:21 AM
That was easy enough, thanks!