Bruce
asked on
In Access, How do I update multiple text boxes without doing a SetFocus for each?
My Access applications has a "calculation" that runs on the press of a button. The calculation updates about 15 text boxes on a split form. I only way I have found to update each one form the code is to do a "SetFocus" right before I call the Me.txt....Text = "".
As one would expect, this implementation has a visual causes the causes the cursor to jump all over the screen and is disconcerting to the user.
First, is there a way to update the fields without having to "SetFocus"?
If not, is there a way to suspend the updating of the screen until all the fields are set and then forcing a "redisplay" or the like...?
As one would expect, this implementation has a visual causes the causes the cursor to jump all over the screen and is disconcerting to the user.
First, is there a way to update the fields without having to "SetFocus"?
If not, is there a way to suspend the updating of the screen until all the fields are set and then forcing a "redisplay" or the like...?
One approach would be to put a word (say, "Update") in the Tag property of each textbox that needs to be updated, then cycle through the controls on the form and requery only these controls. Here is some sample code:
Use the Me argument to run it from the form. This code could be run from a command button or some event.
Public Sub CycleControls(frm As Access.Form)
Dim ctl As Access.Control
On Error Resume Next
For Each ctl In frm.Controls
If ctl.Tag = "Update" Then
ctl.Requery
End If
Next ctl
End Sub
Use the Me argument to run it from the form. This code could be run from a command button or some event.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I tried using split forms once and was not happy with the way they were implemented so stopped doing so a long time ago. Do you really need the split form? A lot of times, when I need some form of datasheet and a data entry form to go with it, I will use a main form, with two subforms (one data sheet, one data entry).
This gives me the ability to select a record in the datasheet subform and display the data entry form associated with that record in the other subform.