setfocus

mavergara

Registered User.
Local time
Yesterday, 20:30
Joined
Jun 27, 2011
Messages
19
im having a problem with setfocus code, when i enter below codes and i click answer 1 I get a runtime error 2110, microsoft access cant move the focus to the control frame 184. kindly advise me what to do to debugg it, there is no problem when I click the answer 2, the frame 184 become disabled. Please help me. Thanks in advance.

Private Sub Frame177_AfterUpdate()
If Me!delivery = "1" Then
Frame184.SetFocus
ElseIf Me.delivery = "2" Then
Me.Frame184.Enabled = False
End If
End Sub
 
Try..

Code:
Private Sub Frame177_AfterUpdate()
If Me!delivery = "1" Then
Frame184.SetFocus
ElseIf Me!delivery = "2" Then
Me.Frame184.Enabled = False
End If
End Sub
 
Or...

Code:
Private Sub Frame177_AfterUpdate()
If Me.delivery = "1" Then
Frame184.SetFocus
ElseIf Me.delivery = "2" Then
Me.Frame184.Enabled = False
End If
End Sub
 
Try..

Code:
Private Sub Frame177_AfterUpdate()
If Me!delivery = "1" Then
Frame184.SetFocus
ElseIf Me!delivery = "2" Then
Me.Frame184.Enabled = False
End If
End Sub


thanks for your quick response. I tried it but i still get the same error. for your reference, i attached my work. kindly help me debug this error. thanks a lot.
 

Attachments

a frame cannot receive focus
 
to make what work? what are you trying to accomplish?
 
to make what work? what are you trying to accomplish?

What I did right now, I closed the access and open again, open the form and I clicked the yes button (1) and the frame184.setfocus DID work, however when I clicked the no button (2) and tried again click the yes button(2) the frame184.setfocus does not work again. please help me, you may try to do it using my access work. hope it make sense to you. thanks for your help

also, does the code that im using is feasible for access 2007? please I badly needed your assistance. Many many thanks!
 
Last edited:
a frame cannot receive focus
Actually a 'frame' can receive Focus, if it's the 'frame' surrounding an Option Group, which it appears to be.

It's hard to tell, though, because while mavergara has told us what he's tried, he hasn't actually told us, in plain-speak, what he's trying to accomplish.

  • Is Frame184 an Option Group?
  • Is Frame184 the correct name?
  • As above, what are you actually trying to do?
Like many here, I don't run Version 2007 and cannot open your attached file.

Linq ;0)>
 
Actually a 'frame' can receive Focus, if it's the 'frame' surrounding an Option Group, which it appears to be.

It's hard to tell, though, because while mavergara has told us what he's tried, he hasn't actually told us, in plain-speak, what he's trying to accomplish.

  • Is Frame184 an Option Group?
  • Is Frame184 the correct name?
  • As above, what are you actually trying to do?
Like many here, I don't run Version 2007 and cannot open your attached file.

thanks for your reply. frame184 is an option group, and i did not change the name, what will happen if that is an option group?

im using access 2007, when I first click the yes option or (1) the program works properly, however, when I click the no button or (2), the yes button will not working at all and I get a runtime error 2110, microsoft access cant move the focus to the control frame. What will I do? Im begging. THanks!
 
when I first click the yes option or (1) the program works properly, however, when I click the no button or (2), the yes button will not working at all and I get a runtime error 2110
Unlike your first post, this one actually pinpoints the problem!

If you select "2," Frame184 is Disabled. If you subsequently select "1" you get the error, because Frame184 is still Disabled, and a Disabled Control cannot receive Focus!

I'm still a little confused, though, as to why, in the AfterUpdate event of Frame177, you're checking the Value of Delivery and setting Frame184 accordingly. Why aren't you doing this in the Delivery_AfterUpdate event?

At any rate, you need to use the Form_Current event, which executes when you move from one Record to another Record and set the Enabled Property for Frame184 accordingly.

Code:
Private Sub Form_Current()
If Me.Delivery = "2" Then
 Me.Frame184.Enabled = False
Else
 Me.Frame184.Enabled = True
End If
End Sub

But you still have a problem! What if you select "2," which Disables Frame184, then come back later and change Delivery to "1" ?

You'll still pop the error, because with Delivery having a Value of "2," Frame184 is still Disabled!

If you don't want the user to be able to change the Delivery Value, once the record is saved, you'll need to Lock it, in the same Form_Current event, if it is not Null.

If you do want the user to be able to change the Delivery Value, you'll have to check for the Enabled Property setting of Frame184 in your original code and set it to True before moving Focus to it.

Linq ;0)>
 
Unlike your first post, this one actually pinpoints the problem!

If you select "2," Frame184 is Disabled. If you subsequently select "1" you get the error, because Frame184 is still Disabled, and a Disabled Control cannot receive Focus!

I'm still a little confused, though, as to why, in the AfterUpdate event of Frame177, you're checking the Value of Delivery and setting Frame184 accordingly. Why aren't you doing this in the Delivery_AfterUpdate event?

At any rate, you need to use the Form_Current event, which executes when you move from one Record to another Record and set the Enabled Property for Frame184 accordingly.

Code:
Private Sub Form_Current()
If Me.Delivery = "2" Then
 Me.Frame184.Enabled = False
Else
 Me.Frame184.Enabled = True
End If
End Sub

But you still have a problem! What if you select "2," which Disables Frame184, then come back later and change Delivery to "1" ?

You'll still pop the error, because with Delivery having a Value of "2," Frame184 is still Disabled!

If you don't want the user to be able to change the Delivery Value, once the record is saved, you'll need to Lock it, in the same Form_Current event, if it is not Null.

If you do want the user to be able to change the Delivery Value, you'll have to check for the Enabled Property setting of Frame184 in your original code and set it to True before moving Focus to it.

Linq ;0)>

thanks for your help, and all the access pro! you are awesome. It works perfectly as I expected:) many thanks again.

I have another question, since the questionnaire is very long, I created 2 forms, the second form is the continuation of the survey. How will I make the two form to become 1 record? Do I need to link the two form, I really have no idea as I put a next record in the second form. the first form still in the first record, but the second form is now in the second record.

Appreciate all your help. Thanks!
 
You don't want to do this with two forms! When a single Record needs more space than can be accommodated on a single screen, without scrolling, you need to use a Tabbed Control.

Tabbed Controls are normally used in one of two ways
  1. To enter/display data in a logical manner from a single RecordSource when one screen won't display all of the Controls for the Record
  2. To enter/display data and related data from multiple RecordSources using subforms on the Tabbed Pages.
An example of #1 would be an employee database.
  • Page 1 could hold personal information, i.e. name, age, gender, SSB, etc
  • Page 2 contact info, i.e. address, home phone number, cell phone number, etc
  • Page 2 education info, high school attended, colleges attended, degrees held
All of the above data would be based on a single table.

An example of #2 would be a products/services database.
  • Page 1 could hold Customer information, i.e. name, contact person, address, phone number
  • Page 2 payment/credit info, i.e. bank info, credit card numbers, in-house credit limits
  • Page 3 services ordered info; type of services, dates requested, costs quoted
  • Page 4 products ordered info; products, quantity, cost-per-unit
The data on these pages would be based on four different but related tables, one for each Tabbed Page.

Your situation, with a survey type form, would fall into the first example given above. Here's a quick little tutorial I give people on the use of Tabbed Pages. It addresses some of the common problems experienced with them:

First thing to remember is that the Tabbed Pages are all part of a single form; think of it as a really long form turned on its side. Because it is all one form, all referencing to any control on it is done in the same manner as if they were all on one single screen. Create a form in Design View. Goto the toolbox and click on the Tabbed Control Icon; it actually looks like several manila file folders. Place it on your form and adjust the size to your liking. If you need more than the two tabbed pages it initially gives you, click on the tabbed control to select it. Goto Insert and click on Tabbed Control Page and another tabbed page will be added. Do this as many times as necessary.

This is the really important part: when you go to add a control to a tabbed page, whether it be a textbox, command button or subform, you must first click to select one of the pages, then add the control. Otherwise, the control will be added to the form itself, and will show thru on all tabbed pages! If a single page has been selected, when your cursor carrying the control appears over the page, a black "insert" will appear.

Once you have the form's Control Source (your table or a query) set up, you simple add controls as you normally would, heeding the above paragraph.

Also important to understand! If you go to move a control from one part of your main form to a tabbed page, you cannot drag and drop it! You must cut it, select the tabbed page, then paste it! And if the control has any code behind it, a GotFocus, OnClick, etc, after dropping it on the tabbed page, you'll have to "re connect" it to its code. Select the control, goto Properties, click to the right of [Event Procedure] on whatever event to bring up the ellipsis (...) then click it to go to the code window. Exit the code editor and the control and its event code will be connected.

One last thing. When trying to access the Properties of the Tabbed Control, such as the BackStyle, people complain that they can't find the property. The problem is that they haven't selected the Tabbed Control, they've selected one of the pages of the Tabbed Control! The best way to be sure of selecting the Tabbed Control itself is to click to the right of the last tab. If you have 2 tabs, for instance, click in the blank area where Tab 3 would be, if you had a Tab 3.

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom