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

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
mdstallaAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
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
 
Rey Obrero (Capricorn1)Commented:
test this

in your db, do  a compact and repair
Final-WUCAINS-rev.accdb
0
 
mdstallaAuthor Commented:
Nope.  Didn't work.  I pressed that button after ever tiny step I took and codes are still being replaced.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Rey Obrero (Capricorn1)Commented:
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
 
mdstallaAuthor Commented:
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
 
Rey Obrero (Capricorn1)Commented:
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
 
mdstallaAuthor Commented:
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
 
Rey Obrero (Capricorn1)Commented:
0
 
mdstallaAuthor Commented:
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
 
mdstallaAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.