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.
Re: Selecting a tab at formload
Are you using the Tabbed Dialog control?
Re: Selecting a tab at formload
Erm, ssTab ?
That wot you asking ?
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
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.
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...
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.
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?
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
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.
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
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:
'get currently selected job in results
Private Sub cmdDisplayJob_Click()
Clipboard.SetText rtbResults.SelText
JobBook.Tab = 0
txtJobNo.Text = Clipboard.GetText
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM JobBook WHERE JobNo = '" & txtJobNo.Text & "'", cn, adOpenDynamic, adLockPessimistic
Call ClearForm
If rs.EOF Or rs.BOF Then
MsgBox "Not records found"
txtJobNo.Text = ""
txtJobNo.SetFocus
Exit Sub
End If
Call FillFields
CurrentJobNo = txtJobNo.Text
rs.Close
Set rs = Nothing
End Sub
Here JobBook.Tab = 0 works fine. It just wont on the FormLoad event !
Jack.
Re: Selecting a tab at formload
did u try the me.jobbook ?
are you building the tabs dynamicaly? this is very strange!
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.
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.
Re: Selecting a tab at formload
Instead of Form_Load use the Form_Activate instead...
VB Code:
Private Sub Form_Activate()
myform.Tab = 0
End Sub
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:
Private Sub Form_Load()
MsgBox ("Notice that this event was done first and no form is present"), vbInformation
End Sub
Private Sub Form_Activate()
MsgBox ("Notice that this event was done last and the form is now present"), vbInformation
End Sub