[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Access 2013:  Sub Form Navigation Button VBA Codes are Replacing Eachother

Posted on 2013-12-23
10
Medium Priority
?
2,139 Views
Last Modified: 2013-12-24
I have several (sub) forms that open from 2 Control Buttons at the bottom of each page (“Back” and “Next”).  I have embedded code into each button so that Access will display the appropriate (sub) forms if/when they are clicked.  The problem I’m facing is that the code I am writing into each button is replacing the code for other buttons.

For example:

When I type in the Code for the Next Button on Form 3, the Code for the Back Button on Form 1 is replaced.

Details:
Sub Form1 (Option Group—‘Offsite’ + Control Button—‘Next’) brings up Sub Form 3.  That is correct!

Sub Form3 (Control Button—‘Back’) brings up Sub Form 1.  That is correct!

Sub Form3 (Option Group—‘Yes’ + Control Button—‘Next’) does not work.  So I re-type the code into Sub Form3’s Control Button—‘Next.’

PROBLEM:  That code I just typed into Sub Form3’s Control Button—‘Next,’ is now appearing in Sub Form3’s Control Button—‘Back.’

Can any help me cure this problem?  I have attached the database; the “Navigation Form1” is the Parent Form with the Sub Forms.

Thanks.
Final-WUCAINS.accdb
0
Comment
Question by:mdstalla
[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
  • 5
  • 5
10 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39737347
test this

in your db, do  a compact and repair
Final-WUCAINS-rev.accdb
0
 

Author Comment

by:mdstalla
ID: 39737385
Nope.  Didn't work.  I pressed that button after ever tiny step I took and codes are still being replaced.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39737392
what do you mean being replaced?

here is the code from "Form3" that I've been testing and it stays intact..

Private Sub Back3_Click()
        DoCmd.BrowseTo acBrowseToForm, "Form1", "Navigation Form1.NavigationSubForm", , , acFormEdit

End Sub

Private Sub Next3_Click()
If Me.OG3 = 1 Then
        DoCmd.BrowseTo acBrowseToForm, "Form4", "Navigation Form1.NavigationSubForm", , , acFormEdit
    ElseIf Me.OG3 = 2 Then
        DoCmd.BrowseTo acBrowseToForm, "Form6", "Navigation Form1.NavigationSubForm", , , acFormEdit
    End If


End Sub
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

Author Comment

by:mdstalla
ID: 39737418
Okay.  Here’s what I do:

Form 1 (Control Button—‘Next’):

VBA Code Entered:
Private Sub Next1_Click()
If Me.OG1 = 1 Then
        DoCmd.BrowseTo acBrowseToForm, "Form2", "Navigation Form1.NavigationSubForm", , , acFormEdit
    ElseIf Me.OG1 = 2 Then
        DoCmd.BrowseTo acBrowseToForm, "Form3", "Navigation Form1.NavigationSubForm", , , acFormEdit
    End If
End Sub

*When operating in Navigation Form1/Form1… Yes, both of these codes work!  Okay, next form….

Form2 (Control Button—‘Back’):

VBA Code Entered:
Private Sub Back2_Click()
DoCmd.BrowseTo acBrowseToForm, "Form1", "Navigation Form1.NavigationSubForm", , , acFormEdit
End Sub

*When operating in Navigation Form1/Sub Form2 (‘Back Button’)… Yes, this code works!  Okay, let’s see how Navigation Form1/Sub Form2 (‘Next Button’) works…

Form2 (Control Button—‘Next’):

VBA Code Entered:
DoCmd.BrowseTo acBrowseToForm, "Form3", "Navigation Form1.NavigationSubForm", , , acFormEdit

*When operating in Navigation Form1/Form2… Yes, that code works!  Okay, next form…

Form3 (Control Button—‘Back’):

VBA Code Entered:
Private Sub Back3_Click()
DoCmd.BrowseTo acBrowseToForm, "Form1", "Navigation Form1.NavigationSubForm", , , acFormEdit
End Sub

*When operating in Navigation Form1/Form3… Yes, that code works!  But before we move on from here; for shits and giggles; let’s just make sure that previously programed Forms are operating as expected.  

Wait a minute!  

Form2 (Control Button—‘Back’), which was just coded with:
Private Sub Back2_Click()
DoCmd.BrowseTo acBrowseToForm, "Form1", "Navigation Form1.NavigationSubForm", , , acFormEdit
End Sub

Is no longer working, and is now coded with…

Private Sub Next2_Click()
DoCmd.BrowseTo acBrowseToForm, "Form3", "Navigation Form1.NavigationSubForm", , , acFormEdit
End Sub
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39738022
did you check, test the db I uploaded?

here it is again..


and, make sure that you hit the save icon after you tested your code
Final-WUCAINS-rev.accdb
0
 

Author Comment

by:mdstalla
ID: 39738692
Okay, I received the Database you sent me and reviewed the first 9 Sub Forms of the Navigation Form.  Here’s what I identified:

Most of the buttons worked (much better than I’ve been able to do on my end).  The only ones that didn’t work (and by that I mean you press the button and nothing happens) were:

Form 4 (Back Button)
Form 5 (Back Button)
Form 6 (Next Button)
Form 7 (Back Button)
Form 8 (Back Button)
Form 9 (Back Button)

So I went into each of these defective button myself, deleted the existing code (saved), and then typed in your codes (saved).  After these adjustments, I re-reviewed the first 9 Sub Forms of the Navigation Form.  

This is a list of the Buttons that don’t work this time (and by that I mean you press the button and nothing happens):

Form 4 (Next Button—Yes)    Access just decided to give it Form 4’s Back Button code
Form 4 (Next Button—No)  

Form 5 (Next Button)      Access just decided to give it Form 5’s Back Button code

Form 6 (Back Button)     Access just decided to give it Form 6’s Next Button code

Form 7 (Next Button—Yes)     Access just decided to give it Form 7’s Back Button code
Form 7 (Next Button—No)

Form 8 (Next Button—Yes)    Access just decided to give it Form 8’s Back Button code
Form 8 (Next Button—No)

Form 9 (Next Button)     Access just decided to give it Form 9’s Back Button code

I’ve attached the database you sent me with my updates to show the problem.  Any help you can give me to resolve this problem would very much appreciated.
Access-Trouble.accdb
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39738760
0
 

Author Comment

by:mdstalla
ID: 39738795
Okay, I got the database you sent me.  I tested Navigation Form1 (Sub Forms 1-9).  Every button functions, but there were a few that opened the wrong Sub Form.  Here’s the list of mis-coded buttons:

Sub Form 4 (Next Button—Yes)     Opens Sub Form 5 when it should open Sub Form 6
Sub Form 6 (Back)     Opens Sub Form 5 when it should open Sub Form 3
Sub Form 7 (Next Button—No)     Opens Sub Form 8 when it should open Sub Form 11
Sub Form 8 (Next Button—No)     Opens Sub Form 9 when it should open Sub Form 10

So again, I went into each mis-coded Button and changed the code (Delete existing code; Save; Input your codes, Save).  I re-tested Navigation Form1 (Sub Forms 1-9).  Here are the newly dysfunctional Buttons:

Sub Form 4 (Back Button)     Access decided to replace this code with Sub Form 4’s Next Button code  

Sub Form 6 (Next Button)     Access decided to replace this code with Sub Form 6’s Back Button code

Sub Form 7 (Back Button)     Access decided to replace this code with Sub Form 7’s Next Button code

Sub Form 8  (Back Button)     Access decided to replace this code with Sub Form 8’s Next Button code

The update Database is attached.
Access-Trouble2.accdb
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1500 total points
ID: 39738841
i don't know exactly what you have been doing, but Access will not change the codes as you have described. I never knew of such behavior that Access will do.

try uninstalling your office or access, reboot your pc and do a clean full installation of office or access.
0
 

Author Closing Comment

by:mdstalla
ID: 39738872
I can’t figure it out either.  What I've done is literally start from scratch-- and re-wrote the entire database with all of the Forms.  If I run into this problem again I will try your suggestion and uninstall office.

Thanks for all of your help.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

656 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