Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 Frames - How Do I Know Which Frame is SetFocus To Save Info

Status
Not open for further replies.

Thuky

MIS
Jun 3, 2003
24
US
Hi,

I need some quick help please.
I am using 2 frames, which I usually use for option buttons, to group some of my combo and text boxes. Even though there are 2 different frames, I just want to have only 1 set of ADD,EDIT, and SAVE buttons to add and edit data. My question is how do I know which frame is SetFocus so I can call my insert and update statements to update info for controls on the frame that I select.

Thanks!
 
Thuky,

Not quite sure what you are saying here, but it seems to me that a little bit of lateral thinking needs to be applied. For example, you say you have 2 frames for option buttons. Obvioulsy 1 frame does something and the other frame does something else? If so, either lock the buttons that you don't want one of the frames to use in your code for example, if you are using frame 1, in the code when an option is clicked, you lock out any buttons you don't want.

A friend of mine told me once not to give the users too many options, if you do, they will crash your db (eventually)

Hope I'm on the right track, If not, you may need to try and explain it a bit better

Cheers

Jedel
 
Is it even possible to do what you are saying?
How are you associating the other controls with the option group control? I am unaware of any mechanism for doing so.

I'm struggling to imagine a situation wher you would want two alternative inputs for the same field, but if that's your approach then wouldn't it be easier to use an option group to select one or the other and then set the other one to enaabled = false or visible = false.

 
Ok, I have 2 frames: 1 frame contains combo box 1 and text box 1 for info in my master table. The other frame that contains combo box 2 and text box 2 for info in my detail table. Also, I have only 1 set of ADD,EDIT, and SAVE of buttons for controls on those 2 frames. When I click on frame 1 (for my Master table), somehow I have to make that frame to set focus so when I ADD or EDIT info from the controls from the selected frame, I can save info in my Master table instead of the Detail table (I have to call the right insert or update statements to update the right table). I have an unbound form (Access project connecting to SQL server 7.0).

Thanks for your help
 
How are ya Thuky . . . . .

You could use the [blue]Screen Objects[/blue] [purple]PreviousControl Property[/purple] to return the name of the previous control that had the focus. Since you know the names of the controls in each frame, coding should be easy. Following is an example of using the property:

Code:
[blue]Dim prevCtl As Control, ctlNam As String
Set prevCtl = [purple]Screen.PreviousControl[/purple]
ctlNam = prevCtl.Name[/blue]
Note: An error will be raised if only one control has had the focus since the form was open and you call this property. So in your forms [blue]On Open Event[/blue], just see to it the focus visits more that one control.


cal.gif
See Ya! . . . . . .
 
Hi Thuky
My original lack of understanding remains.
I see nothing that requires the user ever to click on a frame in order to use the controls 'inside' it. So the Frame may never have the focus.
As TheAceMan1 has indicated you can test for specific previous control names when you click a button.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top