If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
tab order
Thought this could be important. I am working in Access 2003 but in Access
2000 format. Thanks -- cbishop "Ken Snell (MVP)" wrote: Did you try the modified code that I posted? -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... The first line. I'm sorry, I meant to include that. -- cbishop "Ken Snell (MVP)" wrote: On which line of code do you get the error? Might be necessary to move focus to main form first: Private sub Tax_Install_Paid_Date_Exit Me.Parent.NameOfAControlOnMainForm.SetFocus Me.Parent.fsubTax_Bills.SetFocus Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus Me.Parent.fsubTax_Bills.Form.Recordset.AddNew Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus End Sub -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... Ken, I tried it but got a Run-time error '2465', Application defined or object-defined error. I double checked my typing and the subform names and control names but everything looked okay. -- cbishop "Ken Snell (MVP)" wrote: Try this: Private sub Tax_Install_Paid_Date_Exit Me.Parent.fsubTax_Bills.SetFocus Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus Me.Parent.fsubTax_Bills.Form.Recordset.AddNew Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus End Sub -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... I will always want to go to a new record in the Bills subform when logging tax bills. I didn't understand your code, but here is my attempt to use it. subform: fsubTax_Bills; first control on form: Company_ID subform: fsubPayments; last control on form: Tax_Install_Paid_Date Private sub Tax_Install_Paid_Date_Exit Me.Parent.Company_ID.SetFocus Me.Parent.Company_ID.fsubTax_Bills.Company_ID Me.Parent.Company_ID.fsubTax_Bills.Recordset.AddNe w End Sub Thanks for your help -- cbishop "Ken Snell (MVP)" wrote: First, will you *always* want to go to a new record in the Bills subform when you finish entering the data on the Payments subform? If not, you shouldn't program the form to do that all the time. You could put a button on the Payments subform that, when clicked, would take you to a new record on Bills subform: Private Sub ButtonName_Click() Me.Parent.NameOfSubformControlHoldingBillsSubform. SetFocus Me.Parent.NameOfSubformControlHoldingBillsSubform. Form.NameOfControlInBillssubformSetFocus Me.Parent.NameOfSubformControlHoldingBillsSubform. Form.Recordset.AddNew End Sub Otherwise, if you always want to make the move, the code above can be put in the Exit event of the last control of the Payments subform(assuming that there is only one record in that subform). If you have multiple records in the Payments subform, things get complicated to run automatic code, as you'd need to test if you're on the last record and make the move only if it's the last record. -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... I have a form with 2 subforms' Bills and Payments. When bills are logged the Bills subform is completed populated and the Payments subform is partially populated. I want to be able to tab through the last field of the Payments subform and return to the first field of a new record in the Bills subform. The reason I have a payments table is that I may have multiple installments to pay the bill. Thanks in advance. -- cbishop |
#12
|
|||
|
|||
tab order
Two things come to mind:
(1) The code is not running in a subform (no Parent property). However, based on what you've posted, this seems unlikely. However, the error is consistent with this problem. (2) There is an error occurring in another event within the subform that causes that event to be terminated, thus your code isn't able to run. But that often yields an error of "you cannot move focus to that control at this time" or some similar error. Can cboJurisdiction receive the focus on the main form? Perhaps try John Vinson's suggestion of putting focus on the main form itself (which will cause focus to go to a control that can receive the focus): Private sub Tax_Install_Paid_Date_Exit(Cancel As Integer) Me.Parent.SetFocus Me.Parent.fsubTax_Bills.SetFocus Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus Me.Parent.fsubTax_Bills.Form.Recordset.AddNew Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus End Sub What other code do you have in the fsubPayments subform object? -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... Yes, I wrote the first line as: Me.Parent.frmJurisdictions.cboJurisdiction.SetFocu s I tried it with the same results and the debugger highlighted the first line of code. I then deleted the frmJurisdictions out of the code and tried again, same results. -- cbishop |
#13
|
|||
|
|||
tab order
I tried the code you sent, now I get run-time error "2449" There is a invalid
method in an expression. The debugger still highlights the first line of code. There is no other code in the subform fsubPayments. cboJurisdiction can receive the focus, but cboState would probably be better. -- cbishop "Ken Snell (MVP)" wrote: Two things come to mind: (1) The code is not running in a subform (no Parent property). However, based on what you've posted, this seems unlikely. However, the error is consistent with this problem. (2) There is an error occurring in another event within the subform that causes that event to be terminated, thus your code isn't able to run. But that often yields an error of "you cannot move focus to that control at this time" or some similar error. Can cboJurisdiction receive the focus on the main form? Perhaps try John Vinson's suggestion of putting focus on the main form itself (which will cause focus to go to a control that can receive the focus): Private sub Tax_Install_Paid_Date_Exit(Cancel As Integer) Me.Parent.SetFocus Me.Parent.fsubTax_Bills.SetFocus Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus Me.Parent.fsubTax_Bills.Form.Recordset.AddNew Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus End Sub What other code do you have in the fsubPayments subform object? -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... Yes, I wrote the first line as: Me.Parent.frmJurisdictions.cboJurisdiction.SetFocu s I tried it with the same results and the debugger highlighted the first line of code. I then deleted the frmJurisdictions out of the code and tried again, same results. -- cbishop |
#14
|
|||
|
|||
tab order
If you're willing to send me a small version of the database in a zip file,
I'll take a look at it and see what's happening. You can get my email address by looking at the ReplyTo email address (which is munged) and removing the words " this is not real " from the address; what's left is my email address. -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... I tried the code you sent, now I get run-time error "2449" There is a invalid method in an expression. The debugger still highlights the first line of code. There is no other code in the subform fsubPayments. cboJurisdiction can receive the focus, but cboState would probably be better. -- cbishop "Ken Snell (MVP)" wrote: Two things come to mind: (1) The code is not running in a subform (no Parent property). However, based on what you've posted, this seems unlikely. However, the error is consistent with this problem. (2) There is an error occurring in another event within the subform that causes that event to be terminated, thus your code isn't able to run. But that often yields an error of "you cannot move focus to that control at this time" or some similar error. Can cboJurisdiction receive the focus on the main form? Perhaps try John Vinson's suggestion of putting focus on the main form itself (which will cause focus to go to a control that can receive the focus): Private sub Tax_Install_Paid_Date_Exit(Cancel As Integer) Me.Parent.SetFocus Me.Parent.fsubTax_Bills.SetFocus Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus Me.Parent.fsubTax_Bills.Form.Recordset.AddNew Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus End Sub What other code do you have in the fsubPayments subform object? -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... Yes, I wrote the first line as: Me.Parent.frmJurisdictions.cboJurisdiction.SetFocu s I tried it with the same results and the debugger highlighted the first line of code. I then deleted the frmJurisdictions out of the code and tried again, same results. -- cbishop |
#15
|
|||
|
|||
tab order
Ken, I'm new to this. What in munged? I can't find a replyto email address.
I would be happy to send a small version of the database. Please define small. The database is now 1548 KB unzipped. -- cbishop "Ken Snell (MVP)" wrote: If you're willing to send me a small version of the database in a zip file, I'll take a look at it and see what's happening. You can get my email address by looking at the ReplyTo email address (which is munged) and removing the words " this is not real " from the address; what's left is my email address. -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... I tried the code you sent, now I get run-time error "2449" There is a invalid method in an expression. The debugger still highlights the first line of code. There is no other code in the subform fsubPayments. cboJurisdiction can receive the focus, but cboState would probably be better. -- cbishop "Ken Snell (MVP)" wrote: Two things come to mind: (1) The code is not running in a subform (no Parent property). However, based on what you've posted, this seems unlikely. However, the error is consistent with this problem. (2) There is an error occurring in another event within the subform that causes that event to be terminated, thus your code isn't able to run. But that often yields an error of "you cannot move focus to that control at this time" or some similar error. Can cboJurisdiction receive the focus on the main form? Perhaps try John Vinson's suggestion of putting focus on the main form itself (which will cause focus to go to a control that can receive the focus): Private sub Tax_Install_Paid_Date_Exit(Cancel As Integer) Me.Parent.SetFocus Me.Parent.fsubTax_Bills.SetFocus Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus Me.Parent.fsubTax_Bills.Form.Recordset.AddNew Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus End Sub What other code do you have in the fsubPayments subform object? -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... Yes, I wrote the first line as: Me.Parent.frmJurisdictions.cboJurisdiction.SetFocu s I tried it with the same results and the debugger highlighted the first line of code. I then deleted the frmJurisdictions out of the code and tried again, same results. -- cbishop |
#16
|
|||
|
|||
tab order
|
#17
|
|||
|
|||
tab order
I've looked at your database. What you have is three subforms, embedded in
each other, within a main form. That is slightly different from your initial description, but it's not a problem. The following code is what you want to use for the "Got Focus" event of the "relay" textbox that you're using in the most deeply nested subform (the payments subform): Private Sub txtRelay_GotFocus() ' move focus within subform to the first field in the record ' (this is needed so that you can go back into the subform ' after adding a new "bills" record) Me.Tax_Bill_Install_Number.SetFocus ' move focus to the CompanyID control in the second subform ' (the parent of the third subform) Me.Parent.Form!Company_ID.SetFocus ' begin a new record in the "bills" subform Me.Parent.Form.Recordset.AddNew ' set focus to the first control in the new record (just to be sure ' that the focus is where you want it to be) Me.Parent.Form!Company_ID.SetFocus End Sub -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... I tried the code you sent, now I get run-time error "2449" There is a invalid method in an expression. The debugger still highlights the first line of code. There is no other code in the subform fsubPayments. cboJurisdiction can receive the focus, but cboState would probably be better. -- cbishop "Ken Snell (MVP)" wrote: Two things come to mind: (1) The code is not running in a subform (no Parent property). However, based on what you've posted, this seems unlikely. However, the error is consistent with this problem. (2) There is an error occurring in another event within the subform that causes that event to be terminated, thus your code isn't able to run. But that often yields an error of "you cannot move focus to that control at this time" or some similar error. Can cboJurisdiction receive the focus on the main form? Perhaps try John Vinson's suggestion of putting focus on the main form itself (which will cause focus to go to a control that can receive the focus): Private sub Tax_Install_Paid_Date_Exit(Cancel As Integer) Me.Parent.SetFocus Me.Parent.fsubTax_Bills.SetFocus Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus Me.Parent.fsubTax_Bills.Form.Recordset.AddNew Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus End Sub What other code do you have in the fsubPayments subform object? -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... Yes, I wrote the first line as: Me.Parent.frmJurisdictions.cboJurisdiction.SetFocu s I tried it with the same results and the debugger highlighted the first line of code. I then deleted the frmJurisdictions out of the code and tried again, same results. -- cbishop |
#18
|
|||
|
|||
tab order
Thanks Ken, this works, I appreciate the time and effort.
-- cbishop "Ken Snell (MVP)" wrote: I've looked at your database. What you have is three subforms, embedded in each other, within a main form. That is slightly different from your initial description, but it's not a problem. The following code is what you want to use for the "Got Focus" event of the "relay" textbox that you're using in the most deeply nested subform (the payments subform): Private Sub txtRelay_GotFocus() ' move focus within subform to the first field in the record ' (this is needed so that you can go back into the subform ' after adding a new "bills" record) Me.Tax_Bill_Install_Number.SetFocus ' move focus to the CompanyID control in the second subform ' (the parent of the third subform) Me.Parent.Form!Company_ID.SetFocus ' begin a new record in the "bills" subform Me.Parent.Form.Recordset.AddNew ' set focus to the first control in the new record (just to be sure ' that the focus is where you want it to be) Me.Parent.Form!Company_ID.SetFocus End Sub -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... I tried the code you sent, now I get run-time error "2449" There is a invalid method in an expression. The debugger still highlights the first line of code. There is no other code in the subform fsubPayments. cboJurisdiction can receive the focus, but cboState would probably be better. -- cbishop "Ken Snell (MVP)" wrote: Two things come to mind: (1) The code is not running in a subform (no Parent property). However, based on what you've posted, this seems unlikely. However, the error is consistent with this problem. (2) There is an error occurring in another event within the subform that causes that event to be terminated, thus your code isn't able to run. But that often yields an error of "you cannot move focus to that control at this time" or some similar error. Can cboJurisdiction receive the focus on the main form? Perhaps try John Vinson's suggestion of putting focus on the main form itself (which will cause focus to go to a control that can receive the focus): Private sub Tax_Install_Paid_Date_Exit(Cancel As Integer) Me.Parent.SetFocus Me.Parent.fsubTax_Bills.SetFocus Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus Me.Parent.fsubTax_Bills.Form.Recordset.AddNew Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus End Sub What other code do you have in the fsubPayments subform object? -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... Yes, I wrote the first line as: Me.Parent.frmJurisdictions.cboJurisdiction.SetFocu s I tried it with the same results and the debugger highlighted the first line of code. I then deleted the frmJurisdictions out of the code and tried again, same results. -- cbishop |
#19
|
|||
|
|||
tab order
You're welcome.
-- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... Thanks Ken, this works, I appreciate the time and effort. -- cbishop |
#20
|
|||
|
|||
tab order
Hi Ken
I have followed your answer to this question and it works ok with mine,ie when I tab, it move from Main from to Subform1 one then Subform2. I have cut the last two line and used the below code only on the last text field of subform1 to move to the first field of subform2. Private sub Tax_Install_Paid_Date_Exit(Cancel As Integer) Me.Parent.SetFocus Me.Parent.fsubTax_Bills.SetFocus Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus My problem is that after I entered data in Subform1 and tab to subform2, Subform1 become blank. I suspected that it has move to the new data line. If I change the Cycle in Subform1 to "current record",then the above code doesn't works. Both my subforms is single forms and I want to show the record that I last entered on all subform. Could you please help me overcome this problems. Thanks Hong "Ken Snell (MVP)" wrote: I've looked at your database. What you have is three subforms, embedded in each other, within a main form. That is slightly different from your initial description, but it's not a problem. The following code is what you want to use for the "Got Focus" event of the "relay" textbox that you're using in the most deeply nested subform (the payments subform): Private Sub txtRelay_GotFocus() ' move focus within subform to the first field in the record ' (this is needed so that you can go back into the subform ' after adding a new "bills" record) Me.Tax_Bill_Install_Number.SetFocus ' move focus to the CompanyID control in the second subform ' (the parent of the third subform) Me.Parent.Form!Company_ID.SetFocus ' begin a new record in the "bills" subform Me.Parent.Form.Recordset.AddNew ' set focus to the first control in the new record (just to be sure ' that the focus is where you want it to be) Me.Parent.Form!Company_ID.SetFocus End Sub -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... I tried the code you sent, now I get run-time error "2449" There is a invalid method in an expression. The debugger still highlights the first line of code. There is no other code in the subform fsubPayments. cboJurisdiction can receive the focus, but cboState would probably be better. -- cbishop "Ken Snell (MVP)" wrote: Two things come to mind: (1) The code is not running in a subform (no Parent property). However, based on what you've posted, this seems unlikely. However, the error is consistent with this problem. (2) There is an error occurring in another event within the subform that causes that event to be terminated, thus your code isn't able to run. But that often yields an error of "you cannot move focus to that control at this time" or some similar error. Can cboJurisdiction receive the focus on the main form? Perhaps try John Vinson's suggestion of putting focus on the main form itself (which will cause focus to go to a control that can receive the focus): Private sub Tax_Install_Paid_Date_Exit(Cancel As Integer) Me.Parent.SetFocus Me.Parent.fsubTax_Bills.SetFocus Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus Me.Parent.fsubTax_Bills.Form.Recordset.AddNew Me.Parent.fsubTax_Bills.Form.Company_ID.SetFocus End Sub What other code do you have in the fsubPayments subform object? -- Ken Snell MS ACCESS MVP "Cary Bishop" wrote in message ... Yes, I wrote the first line as: Me.Parent.frmJurisdictions.cboJurisdiction.SetFocu s I tried it with the same results and the debugger highlighted the first line of code. I then deleted the frmJurisdictions out of the code and tried again, same results. -- cbishop |
|
Thread Tools | |
Display Modes | |
|
|