?
Solved

set active tab on tabbed control

Posted on 2005-03-18
3
Medium Priority
?
326 Views
Last Modified: 2008-03-06
I have a main form with tabbed control on it. The following Open event for the main form is making the second tab on the form the active tab:

Private Sub Form_Open(Cancel As Integer)

' The underlying recordset for the main form uses lngIndOrg as the primary key
' with lngInd (Individual) as one foreign key and lngOrg (Organization) as the second.
' The subforms on pgInd (the first tab) are linked on lngInd. The subforms on pgOrg
' (the second tab) are linked on lngOrg.

    Me.OrderBy = "lngIndOrgID DESC"
    Me.OrderByOn = True

End Sub

I'm not getting why the OrderBy is making the second tab the active tab. I'd like to make pgInd the active tab without changing the focus from a control on the main form. How would I go about it?

Eli
0
Comment
Question by:eliwil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 58

Expert Comment

by:harfang
ID: 13573151
I don't have the answer. Your code alone should not change the active tab on the tab control...

However, there are two workarounds:

1) save the form once it is open and then remove the Form_Open event. The OrderBy and OrderByOn are saved as form properties and will be active the next time you open it.

2) add the sort order in the form's query. Go to RecordSource and click the builder button [...]. If you are actually creating the query from the table, drag the start to the query grid (select all fields) and then drag the field lngIndOrdID, remove the "show" checkbox and select "sort: descending".

In both cases, the Form_Open event is no longer needed and this should work around your problem.

Hope this helps!
0
 

Author Comment

by:eliwil
ID: 13573369
I went ahead and changed the record source to a query with the desired sort order but am curious about the first work around above. Can you elaborate more on how to implement? Where do I save the form once it is open and how do I then remove the Form_Open event?

Thanks for the help!
0
 
LVL 58

Accepted Solution

by:
harfang earned 2000 total points
ID: 13573478
That is easy:

In design view of the form, the third property is called "Order By". You can check which sort order has been last saved with the form right there. To save the form while open, simply use "File / Save" or the [Save] button on the menu bar. This is actually a misfeature of the Access interface, as most users believe they are saving the -record- and not the -form-. Saving the record is found under "Records / Save record" and the change I have made most for users is to replace the default save button by a "save record" button... No point in saving the form each time you want to save the record, is there?

To remove the Form_Open event, simply delete the entire procedure in the module window:
* find the "On Open" property of the form (in design view)
* press the builder button next to "[Event Procedure]" (the [...])
* double-click in the margin (this selects the procedure)
* press Del.

If there is nothing else in the module, switch back to the form and find the very last property "Has Module" and set it to "No". This will delete the entire module from the form.

Note: make backups first, of course, I don't want you to loose any significant work! :)

Good Luck
0

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question