|
-
Jul 8th, 2005, 06:50 AM
#1
Thread Starter
Addicted Member
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.
-
Jul 8th, 2005, 06:53 AM
#2
Re: Selecting a tab at formload
Are you using the Tabbed Dialog control?
-
Jul 8th, 2005, 08:31 AM
#3
Thread Starter
Addicted Member
Re: Selecting a tab at formload
Erm, ssTab ?
That wot you asking ?
-
Jul 8th, 2005, 08:32 AM
#4
PowerPoster
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
-
Jul 8th, 2005, 08:42 AM
#5
Thread Starter
Addicted Member
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.
-
Jul 8th, 2005, 08:46 AM
#6
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"
-
Jul 8th, 2005, 08:58 AM
#7
Thread Starter
Addicted Member
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.
-
Jul 8th, 2005, 09:17 AM
#8
Re: Selecting a tab at formload
 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?
-
Jul 8th, 2005, 09:19 AM
#9
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"
-
Jul 8th, 2005, 09:19 AM
#10
Thread Starter
Addicted Member
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.
-
Jul 8th, 2005, 09:19 AM
#11
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"
-
Jul 8th, 2005, 09:28 AM
#12
Thread Starter
Addicted Member
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.
-
Jul 8th, 2005, 09:33 AM
#13
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"
-
Jul 8th, 2005, 10:25 AM
#14
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.
-
Jul 8th, 2005, 10:41 AM
#15
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.
-
Jul 8th, 2005, 08:55 PM
#16
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
-
Jul 8th, 2005, 09:01 PM
#17
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|