Losing the focus

Matthew Snook

NW Salmon Database
Local time
Today, 23:50
Joined
Apr 19, 2001
Messages
133
In my attempts to control the users, I have lost control of one of my controls.

I have a subform with stacked controls. In the "ON Current" event of my "Metrics" subform, I check for data in two bound controls. If they are null, I make them invisible; a large button is made visible to cover the area occupied by the (now invisible) empty controls. If either of them contains data, the button is made invisible and the other controls are visible. I had to do this because the query linking the data in the subform will allow edits but not data entry.

Now this button takes the user out to a popup form which accepts data entry into unbound boxes, then contructs an append query and inserts the data into the appropriate table. So far so good. However, upon exiting the popup data entry form the user is again looking at the button in the original subform, which still has the focus! There is now data in the invisible fields, and I'm trying to get the button to go away and the text boxes to show the new data.

I have tried putting code into the popup which would hide the button which called it, but that button still has the focus!

Does anybody know how to get the subform to redraw itself based on new data that was entered in another form?

Thanks,

Matt
 
After returning from the popup form, execute:

Me.Requery

in the subform. That may work by itself - if not, try then explicitly calling the subform's OnCurrent event procedure.
 
Alan:

Thanks for the reply. I tried to call the OnCurrent for the subform (from code in my popup), I was told the object does not support that method. When I put code in the popup instructing the subform to requery, it closes the entire main form down, leaving me with the popup window all alone.

When you say "...after returning from the popup form, execute:...", exactly which event should get the code? Does the button in the subform get the focus back from the popup, or has it kept focus the entire time?

I think I've tried so many approaches that I'm going around in circles now.

Matt
 
Try setting focus to a different field on the form, then make the button invisible and the other boxes visible, then set focus where you want it.
 
My mistake for not being clearer. A form's OnCurrent event procedure is actually named Form_Current, and since it's declared as private it can only be called from within the form itself, which is why you can't reference it from the pop-up. Try the approach just posted by Pat Hartman.
 

Users who are viewing this thread

Back
Top Bottom