Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onleaving a control

Status
Not open for further replies.

nevstic

Instructor
Jul 30, 2002
98
0
0
GB
Hello all
I am trying to check my various controls 0n a form with something like the following
If Isnull me.XXX then
control. set focus.
cancel=true

what I think I need is to get my code to check all controls
in one piece of code rather than duplicate my code for every control,and then say, a vb yesno to undo and continue if the user wants to begin again..
Is this possible ?
thanks in advance
Nick
 
Perform the test in the before update event of the form. That event fires whenever there's an attempt to save, and can be cancelled.

A search here on "validation before update" (in Access forms forum and this) should reveal lot's of samples.

Roy-Vidar
 
If your control names are the same as the field names in the table, you can do it like this for setting properties, a little mod and you can get the values.

For IH = 1 To 19
NM = rst.Fields(IH).Name
Me.Form.Controls.Item(NM).BackColor = 13434828
Me.Form.Controls.Item(NM).BackStyle = 1
Next IH

I use the name of the field to find the control I want.
Takes pre planning but you could also creat a table with the control names in it and go that route.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top