Full Version: Moving focus from one subform to another subform
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
dmiles
I have a form that has multiple subforms with it, I am tryong to move the focus out of one subform to antoher if there is no information input on the first subform, basically trying to get the tab control to move out of the current subform to the next subform. Here is the code

CODE



Private Sub Name_GotFocus()
Dim db As Database
    Set db = CurrentDb
    
    If PriorityLevel = 0 Then
      
        
        
        Form_MHE_Support.Type.SetFocus
        Form_MHE_Support.Type.BackColor = vbRed
      
        
        
        
        DoCmd.CancelEvent
              
      
    Else
      MsgBox "Test"
      
End If
End Sub
theDBguy
Hi,

The safest route is to move the focus in this order:

1. Main Form
2. Subform container
3. Subform
4. Subform Control

Hope that helps...
dmiles
Still lost anyone? I am haveing a pro blem moving the focus,, it seems that the program is overriding my tab and setting the focus back to Name in the first subform when it should be moving the focus to Materials.MHE_support.type
dmiles
I am still not able to move the focus, even trying to move it to the main form first,
Doug Steele
How about you show the code you're currently trying to us, so we can see whether you implemented theDBguy's instructions properly?
dmiles
Here is the code I am trying, still lno luck..

CODE

Private Sub Name_GotFocus()
   Dim db As Database
    Set db = CurrentDb
    Dim Materials As SubForm
    
    Set Materials = Materials
    
    
    If PriorityLevel = 0 Then
      
        Form_frmIncidentSupportBases.SetFocus
  
        Materials.SetFocus
        Form_MHE_Support.SetFocus
        
      
        Form_MHE_Support.Type.BackColor = vbRed
      
        Form_MHE_Support.Type.SetFocus
        
      
      
    Else
      MsgBox "Test"
      
End If
End Sub
dmiles
this does not seem to be that hard of a task, simply move out of the one subform witht the tab and move to a different subform..
theDBguy
Hi dmiles,

No it shouldn't as long as you know the proper syntax to use. Perhaps this table would help.

Good luck!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.