Problem with a startup script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MrDeej
    New Member
    • Apr 2007
    • 157

    Problem with a startup script

    Hello!

    I am trying to make a startup script which selects a predefined TAB page from a form at startup.

    This is how i want it to be:

    I have a table which contains user-data. In this i have a collum called "Startup tab" where the user can predefine which startup page he wants from the tab control. Short explained i want the code to do this job: Me.preffered_ta b.setfocus on startup, and that the preffered tab should be looked up from a table

    For this i use
    Code:
    DLookup("[Startup tab]", "main tbl brukere", "username='" & ntlogin & "'")
    Then, on the form_load event i tried to place this code
    Code:
    Dim ntlogin As String
    Dim su As ???
    
    Init_Globals
    
    ntlogin = Environ("Username")
    
    su = DLookup("[Startup fane]", "main tbl brukere", "Brukernavn='" & ntlogin & "'")
    
    [Form_MAIN Hovedmeny].su.SetFocus
    But this gives me the errorcode of "Method or datamember not found".
    I am pretty sure i need to Dim SU as something (it is dimmed as text in the table), but i dont know what.

    Any suggestions?
  • JConsulting
    Recognized Expert Contributor
    • Apr 2007
    • 603

    #2
    Originally posted by MrDeej
    Hello!

    I am trying to make a startup script which selects a predefined TAB page from a form at startup.

    This is how i want it to be:

    I have a table which contains user-data. In this i have a collum called "Startup tab" where the user can predefine which startup page he wants from the tab control. Short explained i want the code to do this job: Me.preffered_ta b.setfocus on startup, and that the preffered tab should be looked up from a table

    For this i use
    Code:
    DLookup("[Startup tab]", "main tbl brukere", "username='" & ntlogin & "'")
    o
    Then, on the form_load event i tried to place this code
    Code:
    Dim ntlogin As String
    Dim su As ???
    
    Init_Globals
    
    ntlogin = Environ("Username")
    
    su = DLookup("[Startup fane]", "main tbl brukere", "Brukernavn='" & ntlogin & "'")
    
    [Form_MAIN Hovedmeny].su.SetFocus
    But this gives me the errorcode of "Method or datamember not found".
    I am pretty sure i need to Dim SU as something (it is dimmed as text in the table), but i dont know what.

    Any suggestions?

    You have to set the value of the tab control itself.

    Me.TabCtl0.Valu e = 2

    or

    Forms.Form1.Tab Ctl0.Value = 2

    Where 2 is th Tab Index set up in the tab's control properties.

    J

    Comment

    • MrDeej
      New Member
      • Apr 2007
      • 157

      #3
      Thank you!

      I made a table (Main Tab name) which contains the tab.name and tab.nr and i ended up with this code

      Code:
      Private Sub Form_Load()
      
      Init_Globals
      ntlogin = Environ("Username")
      
      Value_preffered_tab = DLookup("[preffered tab]", "Main tbl  users", "username='" & ntlogin & "'")
      tab_nr = DLookup("tabnr", "Main tab name", "Tab name ='" & Value_preffered_tab & "'")
      
      Me.tabctl.Value = tab_nr
      
      End Sub

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by MrDeej
        Hello!

        I am trying to make a startup script which selects a predefined TAB page from a form at startup.

        This is how i want it to be:

        I have a table which contains user-data. In this i have a collum called "Startup tab" where the user can predefine which startup page he wants from the tab control. Short explained i want the code to do this job: Me.preffered_ta b.setfocus on startup, and that the preffered tab should be looked up from a table

        For this i use
        Code:
        DLookup("[Startup tab]", "main tbl brukere", "username='" & ntlogin & "'")
        Then, on the form_load event i tried to place this code
        Code:
        Dim ntlogin As String
        Dim su As ???
        
        Init_Globals
        
        ntlogin = Environ("Username")
        
        su = DLookup("[Startup fane]", "main tbl brukere", "Brukernavn='" & ntlogin & "'")
        
        [Form_MAIN Hovedmeny].su.SetFocus
        But this gives me the errorcode of "Method or datamember not found".
        I am pretty sure i need to Dim SU as something (it is dimmed as text in the table), but i dont know what.

        Any suggestions?
        1. Typically, su would be Declared as a Variant.
          [CODE=vb]Dim su As Variant[/CODE]
        2. When you get a chance, take a look at this Link.
          Accessing Tabs on a Tab Control

        Comment

        Working...