Change Tab on a Form in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The form uses a combo box to pull data to populate the majority of the form.
However there is sometimes data missing.

What I have been asked to do is to check all the fields for null and if null
then change the background color. That one I can figure out. However, they
would like for it to "skip" over the filled in fields when tabbing around the
form. Example:

txtData1 txtData2 txtData3 txtData4 txtData5 etc.
DATA Is Null DATA DATA Is Null

so it would start out with SetFocus on txtData2 then when tabbing, go to
txtData5. I would hate to go into the AfterUpdate event on each text box.

If anyone has any idea how to do this, I would be very appreciative of you
sharing.

TIA

Vanya
 
You will need to run code in the event of each control - probably the
LostFocus event, since
a) AfterUpdate only fires if something was entered, and
b) AfterUpdate is too early.

Each control's LostFocus could call a generic function in a standard module
that moves to the next control.

That would be rather interesting code to write though, since "next control"
is presumably defined by the tab order. It would mean looping through the
controls on the form, skipping any any that don't have a Tab Index property
(such as labels), bypassing any that have Enabled set to Yes or TabStop set
to No, and so finding the next one. Also, if the form has a tab control,
each page has its own Tax Index series, so you would need to determine if
the Parent of the ActiveControl of the form is a tab page, and if so, work
with that page's TaxIndex sequence rather than the form's. And if you are at
the end of the sequence for that tab, you would need to decide whether to go
to the first control in the next tab page, if there is one. It's not just 5
minutes work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top