Access form VB Coding

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top