Possibly On Exit question

C

cricket7

I have a form that I can't seem to figure out how to make the tab be
dependant on the choice that is made from a drop down list. I was
thinking
it might have to do with OnExit. But I don't know. I don't know
code.

When I am in the form and I answer one of the drop down lists, (for
ex. "Reason For Stop" - answer being the list of violations "Moving,
Equipment,
License/Registration") when I tab the curser automatically goes to the
wrong
place to enter the next data. Changing the tab order doesn't work
because
depending on the answer picked the curser has to go to different
places. If
"Moving Violation" is picked then it needs to tab to "Type of Moving
Violation" which is another list box. If "Equipment Violation or
License/Registration Violation" it needs to skip "Type of Moving
Violation"
and move directly to "Result of Stop". It is also weird that
sometimes it
does go to the right place but not consistantly. If I keep entering
Moving
Violation tickets it will go to the right place. But as soon as I
enter
"Equipment or License/Registration" it goes to a different place and
sometimes back to the beginning of entry at the top of the page. If I
have just entered several Moving Violations and then enter an
Equipment Violation it jumps to the beginning of the page. It seems
that as long as I enter the same type of violation it will move to the
right place but once I change to another violation it jumps to the
beginning of the page.

Also, this database I am working in has the time in 2 different data
boxes.
So to enter 8:35 AM you have to put in the first box 08 then tab to
the 2nd
box and enter 35. Is there a way for this to automatically go to the
2nd box
without tabbing so that it is just regular data entry of 0835? I am
wondering also if OnExit is where I need to put something so I can
enter the
time without using the tab.

Thanks,
Pat
 
G

Guest

Yes you can set the focus of Controls (Boxes) on your form but you have not
helped with the names of any controls?

Example

Me.Customers_Part_Number.SetFocus 'Sets the focus to the Control
Customers_Part_Number on the current form.

The same applies to List boxes. The name of the control can be found with
the form in design mode and right click on the control or list box and select
Properties. The name of the control is the first row of the properties box
with the all tab selected (Or the "Other" tab) and is called "Name".

You can direct the focus to go to various controls depending on the content
of your list box.

Something like to following code should be coded into the on change event of
the ListBox (Or the on lost focus event)

If Me.ListBoxName = "Option1" Then
Me.Control1.SetFocus
If Me.ListBoxName = "Options2" Then
Me.Control2.SetFocus
If Me.ListBoxName = "Option3" Then
Me.Control3.SetFocus
Else Me.Control4.SetFocus
End if
End if
End if

You can multi nest the if statments to set the focus where you depending on
many selections.

The Events are available by right clicking the listbox with the form in
design mode and again selecting properties. You will see at the bottom of the
properties window the various events "On Close" "On Open" "On Click" etc.

Click in the event chosen and select code builder a VBA code window will
open with code in as follows.

Private Sub Combo165_Change()

End Sub

Simply paste your code in between the top and bottom lines as follows

Private Sub Combo165_Change()

If Me.ListBoxName = "Option1" Then
Me.Control1.SetFocus
If Me.ListBoxName = "Options2" Then
Me.Control2.SetFocus
If Me.ListBoxName = "Option3" Then
Me.Control3.SetFocus
Else Me.Control4.SetFocus
End if
End if
End if

End Sub

Note I have not included error checking as this is not one of my strong
points.

I hope this helps you sort out your problem.

As a post script or an after thought

This all assumes your controls are on the same form that you have oopen at
the time. If they are on a sub form or another seperate form, you will have
to set focus to the form first (Ensuring that the form is open at the event)

Me.Frm_Price_Break_subform.SetFocus
Me.Frm_Price_Break_subform.Form!Qty_Low.SetFocus

I hope this helps you to at least get on the right road to your solution???
Please let me know?

Kindest Regards

Mike B

--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.
 

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

Similar Threads

Discussion: Privacy 9
auto fill data from a table 2
Help with concatenate 1
Memo Box Problem 4
OnExit 7
Changing tab or OnExit in list box 2
Access violation 5
Key Violations - This might help someone 2

Top