SetFocus / GoToControl question

R

Ron Weaver

I have a search form using an Option Group for Name(Option 1) and Date(Option
2). In the Click event (Frame) either Name or Date fields/combos/lists are
visible. When I click on Date, the Start Date and End Date fields become
visible. I need to SetFocus on the Start Date field. I tried to use the On
Got Focus event on Group Option2 (Date} with a GoToControl command. Access
says I can't do that because the Start Date field is not visible. I thought
that when I clicked on Date it was visible.
Obviously I don't have a clue. Thanks for any help.
Ron Weaver
 
E

Ed Robichaud

You typically use the AfterUpdate event of an option group to fire other
actions; try:

Private Sub MyOptionGroup_AfterUpdate ()

If MyOptionGroup = 2 Then
Me![StartDate].Visible = True
Me![EndDate].Visible = True
Me![MyNameField].Visible = False
Me![StartDate].SetFocus
Else
Me![MyNameField].Visible = True
Me![EndDate].Visible = False
Me![StartDate].Visible=False
Me![MyNameField].SetFocus
End If
End Sub


-Ed
 
R

Ron Weaver

Thanks Ed,
The code stops on the first line. Do I need to modify my On Click code ?
Private Sub Frame15_Click()
Me!cboCustomerName.Visible = (Me!Frame15 = 1)
Me!CustOrders.Visible = (Me!Frame15 = 1)
Me!txtCustomerID2.Visible = (Me!Frame15 = 1)
Me!txtPhone2.Visible = (Me!Frame15 = 1)
Me!cboCustomerDates.Visible = (Me!Frame15 = 2)
Me!CustDates.Visible = (Me!Frame15 = 2)
Me!txtStartDate.Visible = (Me!Frame15 = 2)
Me!txtEndDate.Visible = (Me!Frame15 = 2)
Me!txtCustomerID.Visible = (Me!Frame15 = 2)
Me!txtPhone.Visible = (Me!Frame15 = 2)
Me!Box87.Visible = (Me!Frame15 = 2)
End Sub
I appreciate your help.


Ed Robichaud said:
You typically use the AfterUpdate event of an option group to fire other
actions; try:

Private Sub MyOptionGroup_AfterUpdate ()

If MyOptionGroup = 2 Then
Me![StartDate].Visible = True
Me![EndDate].Visible = True
Me![MyNameField].Visible = False
Me![StartDate].SetFocus
Else
Me![MyNameField].Visible = True
Me![EndDate].Visible = False
Me![StartDate].Visible=False
Me![MyNameField].SetFocus
End If
End Sub


-Ed

Ron Weaver said:
I have a search form using an Option Group for Name(Option 1) and
Date(Option
2). In the Click event (Frame) either Name or Date fields/combos/lists are
visible. When I click on Date, the Start Date and End Date fields become
visible. I need to SetFocus on the Start Date field. I tried to use the On
Got Focus event on Group Option2 (Date} with a GoToControl command. Access
says I can't do that because the Start Date field is not visible. I
thought
that when I clicked on Date it was visible.
Obviously I don't have a clue. Thanks for any help.
Ron Weaver
 
E

Ed Robichaud

Is "Frame15" the name of your option group? Is so, and it's unbound and has
2 choices, then you need to use the AfterUpdate event, not the OnClick event
to trigger your results. See my first post and adopt your specific code
accordingly. The OnClick event will fire anytime you click on the option
group; you want to use AfterUpdate to recognize anytime that an option
choice was changed.
-Ed

Ron Weaver said:
Thanks Ed,
The code stops on the first line. Do I need to modify my On Click code ?
Private Sub Frame15_Click()
Me!cboCustomerName.Visible = (Me!Frame15 = 1)
Me!CustOrders.Visible = (Me!Frame15 = 1)
Me!txtCustomerID2.Visible = (Me!Frame15 = 1)
Me!txtPhone2.Visible = (Me!Frame15 = 1)
Me!cboCustomerDates.Visible = (Me!Frame15 = 2)
Me!CustDates.Visible = (Me!Frame15 = 2)
Me!txtStartDate.Visible = (Me!Frame15 = 2)
Me!txtEndDate.Visible = (Me!Frame15 = 2)
Me!txtCustomerID.Visible = (Me!Frame15 = 2)
Me!txtPhone.Visible = (Me!Frame15 = 2)
Me!Box87.Visible = (Me!Frame15 = 2)
End Sub
I appreciate your help.


Ed Robichaud said:
You typically use the AfterUpdate event of an option group to fire other
actions; try:

Private Sub MyOptionGroup_AfterUpdate ()

If MyOptionGroup = 2 Then
Me![StartDate].Visible = True
Me![EndDate].Visible = True
Me![MyNameField].Visible = False
Me![StartDate].SetFocus
Else
Me![MyNameField].Visible = True
Me![EndDate].Visible = False
Me![StartDate].Visible=False
Me![MyNameField].SetFocus
End If
End Sub


-Ed

Ron Weaver said:
I have a search form using an Option Group for Name(Option 1) and
Date(Option
2). In the Click event (Frame) either Name or Date fields/combos/lists
are
visible. When I click on Date, the Start Date and End Date fields
become
visible. I need to SetFocus on the Start Date field. I tried to use the
On
Got Focus event on Group Option2 (Date} with a GoToControl command.
Access
says I can't do that because the Start Date field is not visible. I
thought
that when I clicked on Date it was visible.
Obviously I don't have a clue. Thanks for any help.
Ron Weaver
 
R

Ron Weaver

Another learning experence. It works perfectly, just what I needed.
Again, thanks for your help.

Ed Robichaud said:
Is "Frame15" the name of your option group? Is so, and it's unbound and has
2 choices, then you need to use the AfterUpdate event, not the OnClick event
to trigger your results. See my first post and adopt your specific code
accordingly. The OnClick event will fire anytime you click on the option
group; you want to use AfterUpdate to recognize anytime that an option
choice was changed.
-Ed

Ron Weaver said:
Thanks Ed,
The code stops on the first line. Do I need to modify my On Click code ?
Private Sub Frame15_Click()
Me!cboCustomerName.Visible = (Me!Frame15 = 1)
Me!CustOrders.Visible = (Me!Frame15 = 1)
Me!txtCustomerID2.Visible = (Me!Frame15 = 1)
Me!txtPhone2.Visible = (Me!Frame15 = 1)
Me!cboCustomerDates.Visible = (Me!Frame15 = 2)
Me!CustDates.Visible = (Me!Frame15 = 2)
Me!txtStartDate.Visible = (Me!Frame15 = 2)
Me!txtEndDate.Visible = (Me!Frame15 = 2)
Me!txtCustomerID.Visible = (Me!Frame15 = 2)
Me!txtPhone.Visible = (Me!Frame15 = 2)
Me!Box87.Visible = (Me!Frame15 = 2)
End Sub
I appreciate your help.


Ed Robichaud said:
You typically use the AfterUpdate event of an option group to fire other
actions; try:

Private Sub MyOptionGroup_AfterUpdate ()

If MyOptionGroup = 2 Then
Me![StartDate].Visible = True
Me![EndDate].Visible = True
Me![MyNameField].Visible = False
Me![StartDate].SetFocus
Else
Me![MyNameField].Visible = True
Me![EndDate].Visible = False
Me![StartDate].Visible=False
Me![MyNameField].SetFocus
End If
End Sub


-Ed

I have a search form using an Option Group for Name(Option 1) and
Date(Option
2). In the Click event (Frame) either Name or Date fields/combos/lists
are
visible. When I click on Date, the Start Date and End Date fields
become
visible. I need to SetFocus on the Start Date field. I tried to use the
On
Got Focus event on Group Option2 (Date} with a GoToControl command.
Access
says I can't do that because the Start Date field is not visible. I
thought
that when I clicked on Date it was visible.
Obviously I don't have a clue. Thanks for any help.
Ron Weaver
 
Top