Microsoft Access
--
Questions
--
Followers
Top Experts
tab between subforms
Hello,
The main form I have for the Access database I am building has many subforms on it.
For speed of data entry the users need to be able to tab between subform as if everything was one big form.
I found solutions that worked for others, especially, the accepted solution to the question at https://www.experts-exchange.com/questions/23754301/Moving-between-subforms-using-setfocus-does-not-move-to-first-field-in-subforms.html, (using the mainsubformtabbing.mdb as an example.
When I tried to implement this code in my database I did not get the desired results.
I modified the code slightly, as I made a unbound box as the last tab position of the first subform (frmaddress) and put the code in both the on ON KEY DOWN and ON EXIT, hoping to move the focus to the first control of the second subform (frmPublication)
When I debugged, I kept getting a COMPILE ERROR, VARIABLE NOT DEFINED for the FORM_FRMPUBLICATION. I noticed that the subform's name was not in the list of CLASS OBJECTS so I changed the subform and control of the code to a subform (subfrmDonations) in the list and control in the CLASS OBJECTS list.
This did put the focus on the control of the subfrmDonations but then the tab jumped back to the frmAddress. (I tried using another subform to direct the focus of the tab to, and got the same results)
I did make a module that declared the public variables.
What are your thoughts?
Attached is both the code used to try and move the tab to frmPublication and frmDonations as well as a screen shot.
Thanks
The main form I have for the Access database I am building has many subforms on it.
For speed of data entry the users need to be able to tab between subform as if everything was one big form.
I found solutions that worked for others, especially, the accepted solution to the question at https://www.experts-exchange.com/questions/23754301/Moving-between-subforms-using-setfocus-does-not-move-to-first-field-in-subforms.html, (using the mainsubformtabbing.mdb as an example.
When I tried to implement this code in my database I did not get the desired results.
I modified the code slightly, as I made a unbound box as the last tab position of the first subform (frmaddress) and put the code in both the on ON KEY DOWN and ON EXIT, hoping to move the focus to the first control of the second subform (frmPublication)
When I debugged, I kept getting a COMPILE ERROR, VARIABLE NOT DEFINED for the FORM_FRMPUBLICATION. I noticed that the subform's name was not in the list of CLASS OBJECTS so I changed the subform and control of the code to a subform (subfrmDonations) in the list and control in the CLASS OBJECTS list.
This did put the focus on the control of the subfrmDonations but then the tab jumped back to the frmAddress. (I tried using another subform to direct the focus of the tab to, and got the same results)
I did make a module that declared the public variables.
What are your thoughts?
Attached is both the code used to try and move the tab to frmPublication and frmDonations as well as a screen shot.
Thanks
<!---------------------------------------------frmPublication----------------------------------->
Option Compare Database
Option Explicit
Private Sub Text26_Exit(Cancel As Integer)
If varTabKeyDown = True Then
If varShiftKeyDown = False Then
varTabKeyDown = False 'Must do this before setting the focus of the destination control
Form_frmPublication.OBOBQUANTIY.SetFocus
End If
End If
varTabKeyDown = False
varShiftKeyDown = False
End Sub
Private Sub Text26_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 9 Then
varTabKeyDown = True
If Shift = 1 Then
varShiftKeyDown = True
End If
End If
End Sub
<!----------------------------------------------subfrmDonations-------------------------------------->
Option Compare Database
Option Explicit
Private Sub Text26_Exit(Cancel As Integer)
If varTabKeyDown = True Then
If varShiftKeyDown = False Then
varTabKeyDown = False 'Must do this before setting the focus of the destination control
Form_subfrmDonations.[ENTRY DATE].SetFocus
End If
End If
varTabKeyDown = False
varShiftKeyDown = False
End Sub
Private Sub Text26_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 9 Then
varTabKeyDown = True
If Shift = 1 Then
varShiftKeyDown = True
End If
End If
End Sub
main-form.JPG
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
ASKER CERTIFIED SOLUTION
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
OK, I could not get either of the above suggestions to work.
I did however find this on the internet and it works!
Parent.SetFocus
Parent.Subform2.SetFocus
Parent.Subform2.Form!contr olname.Set Focus
For some reason, I had to remake the subform I was trying to tab into. When I used my original form (I designed the database in Access 2003 and am using it in Access 2007, the file is an Access 2000 file though)
When I set Subform2 as the original subform (frmPublications) I got a run_time error '438': Object doesn't support this property of method.
I did however find this on the internet and it works!
Parent.SetFocus
Parent.Subform2.SetFocus
Parent.Subform2.Form!contr
For some reason, I had to remake the subform I was trying to tab into. When I used my original form (I designed the database in Access 2003 and am using it in Access 2007, the file is an Access 2000 file though)
When I set Subform2 as the original subform (frmPublications) I got a run_time error '438': Object doesn't support this property of method.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Microsoft Access
--
Questions
--
Followers
Top Experts
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.