E
efandango
The control is a selector field that the user uses to select an address
choice to match a corresponding field on another form, but the code I am
using for this process retains the focus on the Selector Field which means I
can’t say for example; if this selection matches the corresponding target
field, and then make this selection field invisible. The purpose of making it
invisible is so that the user has an ever shrinking list of selections to
choose from, gradually making each one invisible until there are no more
choices left.
Is there another approach to this problem?
Below is my existing code which allows the user to select any field on the
Selection Form/Field and place it in the first available empty slot on the
other Target Form/Field.
All works well, except for the routine that I want to hide the selection
that has been correctly processed; which is:
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] =
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Me.Waypoint_Selector.Visible = False
Instead I get the error: ‘You can’t hide a control that has the focus’.
Which is perfectly understandable, but means that I can’t have my diminishing
list.
Both Forms are Continous.
The Full Code:
Private Sub Waypoint_Selector_Click()
If IsNull(Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Me.Waypoint_Selector
Parent.frm_Run_Test.SetFocus
Parent.frm_Run_Test.Form.Waypoint_Combo.SetFocus
DoCmd.GoToControl "Waypoint_Combo"
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] <>
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Null
End If
Else
Parent.frm_Run_Test.SetFocus
Parent.frm_Run_Test.Form.Waypoint_Combo.SetFocus
RunCommand acCmdRecordsGoToNext
If IsNull(Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Me.Waypoint_Selector
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] <>
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Null
End If
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] =
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Me.Waypoint_Selector.Visible = False
End If
Else
MsgBox "All fields are filled"
End If
End If
choice to match a corresponding field on another form, but the code I am
using for this process retains the focus on the Selector Field which means I
can’t say for example; if this selection matches the corresponding target
field, and then make this selection field invisible. The purpose of making it
invisible is so that the user has an ever shrinking list of selections to
choose from, gradually making each one invisible until there are no more
choices left.
Is there another approach to this problem?
Below is my existing code which allows the user to select any field on the
Selection Form/Field and place it in the first available empty slot on the
other Target Form/Field.
All works well, except for the routine that I want to hide the selection
that has been correctly processed; which is:
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] =
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Me.Waypoint_Selector.Visible = False
Instead I get the error: ‘You can’t hide a control that has the focus’.
Which is perfectly understandable, but means that I can’t have my diminishing
list.
Both Forms are Continous.
The Full Code:
Private Sub Waypoint_Selector_Click()
If IsNull(Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Me.Waypoint_Selector
Parent.frm_Run_Test.SetFocus
Parent.frm_Run_Test.Form.Waypoint_Combo.SetFocus
DoCmd.GoToControl "Waypoint_Combo"
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] <>
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Null
End If
Else
Parent.frm_Run_Test.SetFocus
Parent.frm_Run_Test.Form.Waypoint_Combo.SetFocus
RunCommand acCmdRecordsGoToNext
If IsNull(Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Me.Waypoint_Selector
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] <>
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] = Null
End If
If (Forms.Runs.[frm_Run_Test].Form.[Waypoint_Combo] =
Forms.Runs.[frm_Run_Test].Form.[Run_waypoint]) Then
Me.Waypoint_Selector.Visible = False
End If
Else
MsgBox "All fields are filled"
End If
End If