472,993 Members | 2,149 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

Custom Navigation Button Woes

I am having some trouble with some old code revolving around custom
form navigation buttons. My main form has a sub-form with these custom
navigation buttons. In other words, the code should be modular and
work across forms and sub-forms. My previous code was taken from the
Access Expert Solutions 97 (Leszynski) many years ago. As my database
became more complex with multiple sub-forms and intricate combo boxes,
the code faltered.

Some excerpts from the code follow. These areas may point to some of
the idiosyncrasies. Error handling has been excludes for this post.
Private Sub btnNext_Click()

Call FrmFocusSave(Screen.PreviousControl)
Call FrmNavGotoNext(Screen.ActiveForm)
Call FrmFocusRestore

End Sub

Public Sub FrmFocusSave(ctl As Control)
' Purpose: Save a pointer to the active control

Set mctlFocusSave = ctl ' Save the pointer
End Sub
Public Sub FrmNavGotoNext(rfrm As Form)
' Purpose: Goto next record in form recordset

If rfrm.mtdValidate Then ' Record is valid
If Not FrmNavIsLast(rfrm) Then
rfrm.SetFocus ' Just to be sure
Application.RunCommand acCmdRecordsGoToNext
End If
End If
End Sub

Screen.ActiveForm seems to have issues when placed behind the
navigation buttons of a sub-form. The Screen.ActiveForm grabs the
main form (not the sub-form). Screen.PreviousControl may have a
similar effect. The screen method does not aid the debugging process
since the debugging window has focus not a form. Maybe, another
approach exist. Please let me know another approach to custom
navigation buttons. In addition, how does acquire the previous
control and active form in a bulletproof manner.

The sub-form may have additional issues, but I save the specifics for
the next post. Just keep in mind that each form may be open by another
form in dialog mode. So I am continually jumping from one form to
another. The custom navigation button should allow for this usage.

Nov 12 '05 #1
1 3439
I have some additional details about my database dilemma.

My original custom navigation buttons perform as expect if you open
the form in normal view. The custom navigation buttons falter when you
open the form on a particular record. In other words, open the Project
form the database window, the navigation buttons work. Open the
Project form and select the Company tab, then press the command
button, which opens the Company form on the selected company record,
the custom navigation button stumble. Maybe, the custom navigation
buttons trip on filtered forms (hmm).

Please let me know if you have any workarounds for this situation.
The code for the command button follows. Does anybody have a better
way for opening forms with a command button? In addition, I could
still use another approach to custom navigation buttons.
Private Sub cmdGoComp_Click()

Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "frmComp"

strLinkCriteria = "[CompID]=" & Me![tblComp.CompID]
DoCmd.OpenForm strDocName, , , strLinkCriteria, acFormEdit,
acWindowNormal

End Sub
On Wed, 04 Feb 2004 11:52:13 -0800, Robert Neville
<robert_neville@y@h0o.com> wrote:
I am having some trouble with some old code revolving around custom
form navigation buttons. My main form has a sub-form with these custom
navigation buttons. In other words, the code should be modular and
work across forms and sub-forms. My previous code was taken from the
Access Expert Solutions 97 (Leszynski) many years ago. As my database
became more complex with multiple sub-forms and intricate combo boxes,
the code faltered.

Some excerpts from the code follow. These areas may point to some of
the idiosyncrasies. Error handling has been excludes for this post.
Private Sub btnNext_Click()

Call FrmFocusSave(Screen.PreviousControl)
Call FrmNavGotoNext(Screen.ActiveForm)
Call FrmFocusRestore

End Sub

Public Sub FrmFocusSave(ctl As Control)
' Purpose: Save a pointer to the active control

Set mctlFocusSave = ctl ' Save the pointer
End Sub
Public Sub FrmNavGotoNext(rfrm As Form)
' Purpose: Goto next record in form recordset

If rfrm.mtdValidate Then ' Record is valid
If Not FrmNavIsLast(rfrm) Then
rfrm.SetFocus ' Just to be sure
Application.RunCommand acCmdRecordsGoToNext
End If
End If
End Sub

Screen.ActiveForm seems to have issues when placed behind the
navigation buttons of a sub-form. The Screen.ActiveForm grabs the
main form (not the sub-form). Screen.PreviousControl may have a
similar effect. The screen method does not aid the debugging process
since the debugging window has focus not a form. Maybe, another
approach exist. Please let me know another approach to custom
navigation buttons. In addition, how does acquire the previous
control and active form in a bulletproof manner.

The sub-form may have additional issues, but I save the specifics for
the next post. Just keep in mind that each form may be open by another
form in dialog mode. So I am continually jumping from one form to
another. The custom navigation button should allow for this usage.


Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stephen | last post by:
This is a real brain-teaser and i'd really appreciate it if someone can try and understand what im trying to do and give me a few pointers or ideas to help me work out my problem. Im basically...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
0
by: sd | last post by:
I have created a custom navigation control that I'm registering with the set of aspx pages that will call it. The navigation control will display or hide various navigation elements based on the...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
27
by: Wayne | last post by:
I've been clicking around Access 2007 Beta 2 and can't see the custom menu bar designer. Is it in the beta? Maybe I'm blind. The question that comes to mind is: Will custom menu bars be the same...
1
by: Jakob Lithner | last post by:
When I started a new ASP project I was eager to use the login facilities offered in Framework 2.0/VS 2005. I wanted: - A custom principal that could hold my integer UserID from the database -...
4
by: aaronyoung | last post by:
I have created custom navigation buttons and Record Number indicators on several forms that are used to review and update records based on a query. My On Current event to update the "Record X of...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.