Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tab Controls on Forms

Status
Not open for further replies.

GirlBlonde

Programmer
Oct 30, 2007
94
AU
I have used tab controls on some forms and i want to automatically open one of my tab control forms depending on the input of another input form i have. So that could be the second tab that opens, or the third tab etc. How do i specify which tab to open? can i do that? i have done the docmd. but it doesnt open the tab up.

Energy & persistance conquer all things!
 
i have since figured this one out myself no need for anyone to respond. thanks.

Energy & persistance conquer all things!
 
How are ya GirlBlonde . . .

A starting point:
Code:
[blue]Me![[purple][b]TabControlName[/b][/purple]] = idx[/blue]
Where idx is the page number of the tab (left to right).

Note idx starts at zero . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Hoooooooold On There GirlBlonde! . . .

One of the things missing in this thread is the event your using to trigger the code. [blue]This could make a big difference![/blue] If what follows doesn't work, at least post back the event your using. With this in mind, consider the following:

To my knowledge, moving the focus to a control on a subform is a [blue]two step process[/blue]:
[ol][li]Move the focus to the subform.[/li]
[li]Move the focus to the control.[/li][/ol]
This generates the following code:
Code:
[blue]   [green]'Set focus to the tab page[/green]
   Me.Parent!TabCtl47.Pages("EEinfo").SetFocus
   
   [green]'Set focus to the subform[/green]
   Me.Parent!child54.SetFocus
   
   [green]'Set focus to the control[/green]
   Me.Parent!child54.Form!StatusA.SetFocus[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Hey Aceman!

hows it going! I actually figured out my problem, but today have come accross yet another dilema. Am building a major system thats causing me to age before my time and deadline is approaching way to fast! I keep using the code [Forms]![Frm_DriverFleetDetails]![Frm_SubFrmPoolDrivers].[Form]![btnID] but it still does not pick up the field within the subform on the tab form in the code. i have tried and tried a MILLION things. also with my last question i had i am not sure if you checked another bug i am still stumped at for some reason it is choosing to take a record only one, and duplicate it??? arrgghhh. god give me strength! sometimes i wonder why i do this. i know your probably sick of me but any suggestions?

Energy & persistance conquer all things!
 
Easy does it GirlBlonde . . .
GirlBlonde said:
[blue]I keep using the code [Forms]![Frm_DriverFleetDetails]![Frm_SubFrmPoolDrivers].[Form]![btnID] but [purple]it still does not pick up the field within the subform . . .[/purple][/blue]
[ol][li]Is the code above running in the main or subform?[/li]
[li]Is your intent to [blue]read[/blue], [blue]write[/blue], or [blue]set focus[/blue] to the field?[/li]
[li]Are you sure of the [blue]spelling[/blue] of form & control names?[/li][/ol]
Be aware: A [blue]Tab Control[/blue] is strictly a visual interface. You reference controls and subforms as if it weren't there.
GirlBlonde said:
[blue] . . . for some reason it is choosing to take a record only one, and [purple]duplicate it???[/purple][/blue]
You have code somewhere making the copy (probably setting the Default of the controls). And so I know where on the same page, this is happening on the subform . . . yes?

You'll have to scan thru the forms code module for this. If it gets to be a little too much and the line count of the code in the forms module is not forbidding, post it here for analysis . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
hey aceman1

bad day today nothing seems to be going right. i have bigger problems to fry than the tab i have pretty much figured it out although it still doesnt work for particular items? Thanks for all your helpfull input.but as i said way to many problems to worry about than that now. i have below the code i have tried simplifing a little if you can have a look at it and see if you can identify where the bug is that would be great. On the verge of nervous breakdown i think! sometimes i think access is more trouble than its worth but then i realise its just me!! Oh well Ho Ho Ho huh.Thanks.

On Error GoTo ErrorHandler

Dim lst As Access.ListBox
Dim varItem As Variant
Dim lngID As String

Set lst = Me![ListDrivers]

'Clear old temp table
DoCmd.SetWarnings False
strSQL = "DELETE * from Tbl_CostIDsMultiSelected"
DoCmd.RunSQL strSQL

'Check that at least one contact has been selected

If lst.ItemsSelected.Count = 0 Then
MsgBox "Please select at least one driver"
lst.SetFocus
Exit Sub
End If

For Each varItem In lst.ItemsSelected

DoCmd.SetWarnings False

'All information is present; write a record to the temp table
lngID = lst.Column(0, varItem)

Debug.Print "Selected ID: " & lngID

strSQL = "INSERT INTO Tbl_CostIDsMultiSelected (RegNo, DriverFirstname, " _
& "DriverSurname) " _
& "SELECT RegNo, DriverFirstname, DriverSurname)" _
& "WHERE RegNo = '" & lngID & "';"
DoCmd.RunSQL strSQL
Next varItem
DoCmd.RunSQL strSQL

DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE Tbl_CostIDMultiselectHoldingBay.*FROM Tbl_CostIDMultiselectHoldingBay"
DoCmd.OpenQuery "Qry_SelectedCostIDsToHoldingBay"
DoCmd.SetWarnings True

ErrorHandlerExit:
Exit Sub

ErrorHandler:
MsgBox "Error No: " & Err.number & "; Description: " & Err.Description
Resume ErrorHandlerExit

Energy & persistance conquer all things!
 
GirlBlonde . . .
Code:
[blue][tt]Change:Dim lst As Access.ListBox
To    :Dim lst As ListBox[/tt][/blue]
The following is a biggy!:
Code:
[blue]strSQL = "INSERT INTO Tbl_CostIDsMultiSelected " & _
                      "(RegNo, DriverFirstname, DriverSurname) " & _
         [red][b]"SELECT RegNo, DriverFirstname, DriverSurname)" & _
         "WHERE RegNo = '" & lngID & "';"[/b][/red][/blue]
In the highlighted Select statement . . . where's the source table or query or SQL! [surprise]
Then after you loop thru the listbox & insert per item:
Code:
[blue]   strSQL = "INSERT INTO Tbl_CostIDsMultiSelected " & _
                         "(RegNo, DriverFirstname, DriverSurname) " & _
            "SELECT RegNo, DriverFirstname, DriverSurname)" & _
            "WHERE RegNo = '" & lngID & "';"
   DoCmd.RunSQL strSQL
Next varItem
   [purple][b]DoCmd.RunSQL strSQL[/b][/purple]
[/blue]
You insert the last item again after the for/next loop is completed! . . . [blue]This is the duplicate record![/blue] [surprise]

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top