Results 1 to 17 of 17

Thread: Selecting a tab at formload

  1. #1

    Thread Starter
    Addicted Member J@ck's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    179

    Selecting a tab at formload

    Wotcha, follks.

    I'm trying to select myform.tab = 0 on the formload event, but it keeps giving me a 'Run-time error '5': Invalid procedure call or argument before exiting the program!

    I searched through the forums, but can find no help. In fact what I'm doing seems to be correct!

    Can anyone help at all?

    Much ta.

    Jack.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Selecting a tab at formload

    Are you using the Tabbed Dialog control?

  3. #3

    Thread Starter
    Addicted Member J@ck's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    179

    Re: Selecting a tab at formload

    Erm, ssTab ?

    That wot you asking ?

  4. #4
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Selecting a tab at formload

    You are getting the error because the form doe snot have a tab. You need to reference the control. ie;

    sstabs.tab = 0

  5. #5

    Thread Starter
    Addicted Member J@ck's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    179

    Re: Selecting a tab at formload

    I'm confused.

    ssTab.tab = 0 ..........gives me an 'object required' error.

    mytab.tab = 0 ......works fine elsewhere in my code, just not on FormLoad !



    Jack.

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Selecting a tab at formload

    I am assuming the name of the ssTab control is mytab?

    if so , thats very strange.. I have an app that uses an sstab and I set it = 0 on load

    ssTab1.Tab = 0

    post the form_load code...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7

    Thread Starter
    Addicted Member J@ck's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    179

    Re: Selecting a tab at formload

    Code:
    'FORM LOAD
    Private Sub Form_Load()
    
    CurrentJobNo = ""
    
    txtDate.Text = Format(Date, "dd mmm yy")
    txtDateWorksReq.Text = Format(Date, "dd mmm yy")
    txtContact.Text = "As Customer"
    cmbJobType.Text = "Locksmith"
    DDate = Date
    JDate = Date
    
    Set cn = New ADODB.Connection
        cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=z:\JobBook.mdb;"
        cn.Open
    
    
    'fill combo boxes
    
    ' ...............about 70 x additems go here.
    
    JobBook.tab = 0
    
    End Sub
    I've omitted out all the additems. JobBook is the name of my tabs. That line works absolutely fine elsewhere in my code - selecting relevant tabs (of which I have 6) no problem.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Selecting a tab at formload

    Quote Originally Posted by J@ck
    I'm confused.

    ssTab.tab = 0 ..........gives me an 'object required' error.

    mytab.tab = 0 ......works fine elsewhere in my code, just not on FormLoad !



    Jack.
    Is the ssTab control on the form in which you have the code in the Form Load event?

  9. #9
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Selecting a tab at formload

    do you re-type that into the forum window? or did you simply Paste it in..

    reason I ask is something is wrong with the name of your tab control..
    if that were the correct name of the control .tab would be .Tab (Capital T)

    if you pasted the code in here.. then you dont have the correct control name
    try typing Me. in your form_load sub.. you should be able to see all controls etc for your form... find it in the list and then add the .Tab
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  10. #10

    Thread Starter
    Addicted Member J@ck's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    179

    Re: Selecting a tab at formload

    * Code in main and only form. Yep.

    * The lower caps .tab is my fault. I typed it in there to show what I wanted to do. When I type it in VB6, it formats to caps fine.

  11. #11
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Selecting a tab at formload

    Exactly what I was trying to get at Hack! lol.. you just asked it the nice easy way! lol
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  12. #12

    Thread Starter
    Addicted Member J@ck's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    179

    Re: Selecting a tab at formload

    Take this for example.

    On another Tab, say Tab3, I have a list of results. If the user highlights a job number, and then clicks on a button (code below), it displays the relevant tab which shows them details of the job.

    VB Code:
    1. 'get currently selected job in results
    2. Private Sub cmdDisplayJob_Click()
    3.  
    4. Clipboard.SetText rtbResults.SelText
    5.  
    6. JobBook.Tab = 0
    7. txtJobNo.Text = Clipboard.GetText
    8.  
    9. Set rs = New ADODB.Recordset
    10.     rs.Open "SELECT * FROM JobBook WHERE JobNo = '" & txtJobNo.Text & "'", cn, adOpenDynamic, adLockPessimistic
    11.  
    12.     Call ClearForm
    13.  
    14.     If rs.EOF Or rs.BOF Then
    15.         MsgBox "Not records found"
    16.         txtJobNo.Text = ""
    17.         txtJobNo.SetFocus
    18.         Exit Sub
    19.     End If
    20.  
    21.     Call FillFields
    22.    
    23.     CurrentJobNo = txtJobNo.Text
    24.            
    25.     rs.Close
    26. Set rs = Nothing
    27.  
    28. End Sub

    Here JobBook.Tab = 0 works fine. It just wont on the FormLoad event !

    Jack.

  13. #13
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Selecting a tab at formload

    did u try the me.jobbook ?
    are you building the tabs dynamicaly? this is very strange!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  14. #14
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Selecting a tab at formload

    If the Tab property is not set to 0 at design time, the Click event will fire when the Tab property gets set to 0 in Form_Load.

    Do you have code in the tab's Click event? The error is probably being raised by that code.

  15. #15
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Selecting a tab at formload

    Attached is a small example using the SSTab control and I have no problem with setting that Tab I want to be active in the Form Load.

    Hope this helps.

  16. #16
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Selecting a tab at formload

    Instead of Form_Load use the Form_Activate instead...

    VB Code:
    1. Private Sub Form_Activate()
    2.     myform.Tab = 0
    3. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  17. #17
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Selecting a tab at formload

    Yeah use Form_Activate. The Form_Load event is fired before the form is even loaded! Form_Activate is fired after the Form is loaded

    Try this as an experiment:

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3.      MsgBox ("Notice that this event was done first and no form is present"), vbInformation
    4.  
    5. End Sub
    6.  
    7. Private Sub Form_Activate()
    8.  
    9.      MsgBox ("Notice that this event was done last and the form is now present"), vbInformation
    10.  
    11. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width