Access form VB Coding

G

Guest

Thought I'd try a new post on this one.
I have a form where the fields/control boxes have drop down lists.
If a certain option is selected I want the cursor (or focus) to goto another
field of my choice. The code below will do what I need if any option from
the drop down list is selected whereas I want to specify different selections
will move to different fields.. Thanks.

Private Sub ComboName_Change()
Me.[FieldName].SetFocus
End Sub
 
D

Douglas J Steele

First, use the AfterUpdate event instead.

It sounds as though you want something like:

Private Sub ComboName_AfterUpdate()
Select Case Me.ComboName
Case Value1, Value2
Me.[FieldNameA].SetFocus
Case Value3
Me.[FieldNameB].SetFocus
Case Value4
Me.[FieldNameC].SetFocus
End Select
End Sub
 
G

Guest

Am I right in saying I should replace the value1 with the selection?

Douglas J Steele said:
First, use the AfterUpdate event instead.

It sounds as though you want something like:

Private Sub ComboName_AfterUpdate()
Select Case Me.ComboName
Case Value1, Value2
Me.[FieldNameA].SetFocus
Case Value3
Me.[FieldNameB].SetFocus
Case Value4
Me.[FieldNameC].SetFocus
End Select
End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


FerrariWA said:
Thought I'd try a new post on this one.
I have a form where the fields/control boxes have drop down lists.
If a certain option is selected I want the cursor (or focus) to goto another
field of my choice. The code below will do what I need if any option from
the drop down list is selected whereas I want to specify different selections
will move to different fields.. Thanks.

Private Sub ComboName_Change()
Me.[FieldName].SetFocus
End Sub
 
D

Douglas J Steele

You should be replacing all of the Valuen things with the actual values you
need to check for (be they numeric or text).

You should be replacing all of the FieldName* things with the actual control
names.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


FerrariWA said:
Am I right in saying I should replace the value1 with the selection?

Douglas J Steele said:
First, use the AfterUpdate event instead.

It sounds as though you want something like:

Private Sub ComboName_AfterUpdate()
Select Case Me.ComboName
Case Value1, Value2
Me.[FieldNameA].SetFocus
Case Value3
Me.[FieldNameB].SetFocus
Case Value4
Me.[FieldNameC].SetFocus
End Select
End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


FerrariWA said:
Thought I'd try a new post on this one.
I have a form where the fields/control boxes have drop down lists.
If a certain option is selected I want the cursor (or focus) to goto another
field of my choice. The code below will do what I need if any option from
the drop down list is selected whereas I want to specify different selections
will move to different fields.. Thanks.

Private Sub ComboName_Change()
Me.[FieldName].SetFocus
End Sub
 

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

Top