2
votes

I trying to use TabControls for subforms in an Access Form.

I have a subform embedded on a page of a TabControl. I meed to move from the last data entry field in the Main Form to the first data entry field in the Subform.

When I SetFocus to the Control in the subform, it does not allow editing without clicking on the TextBox. Is there a command for immediately enabling editing?

Private Sub ReadDate_AfterUpdate()
  Dim myControl As Control
  Set myControl = Forms!Data_Input!BOD_Data_Subform!textBoxToEdit

  myControl.SetFocus
End Sub

Thanks in advance for any suggestions.

1
Not sure what you're asking? If they click on the text box and they can start editing, how else would you start editing the textbox? Are you talking about programmatically changing the textbox contents - that doesn't work? - dbmitch
@dbmitch - When they hit either tab or enter to commit the data change, I would like the cursor to blink in the TextBox. I just realized that if you hit the tab twice (or return once and tab once), the cursor does blink inside the TextBox. - PhillipOReilly
Blinking inside the textbox? Is that what you're referring to as "enabling editing"? - dbmitch
Yes, blinking inside the TextBox. - PhillipOReilly

1 Answers

1
votes

Two steps required to select a control on a subform from a main form
Do the following in order:

  • Select the subform control.
  • Select the appropriate control on the subform.

Example code

Private Sub ReadDate_AfterUpdate()
  Dim myControl As Control

  ' Select the subform control first
  Forms!Data_Input!BOD_Data_Subform.SetFocus
  Doevents

  ' Select the control on the subform.
  Forms!Data_Input!BOD_Data_Subform.Form!textBoxToEdit.SetFocus
End Sub

* Edits *

I suspect answer would work if there were not TabControls in Main Form. It is a two-part process but in this case the first step is:

Forms!Data_Input!subDataTabControl.Pages(0).SetFocus

Where subDataTabControl is name of the Tab Control and 0 give page index.