form naviagtion buttons

Leong

Registered User.
Local time
Today, 20:51
Joined
Jan 10, 2007
Messages
21
Hi

I would like to produce navigation buttons so that when I click for example "back" button I can naviagte from Form1 to the main menu.

I have currently experimented with some code ( am not a programmer )
and edited a Open Form button to include this code "doCmd.Close. The code in total looks like this:


Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

DoCmd.Close

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "User Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub


However, it is not a smooth navigation between forms, as it closes one form and opens another form.

any better ideas?
 
You can build a macro to open or close certain forms. Then use a command button and select run macro.
 
I'm not sure what you want but,

If you want to switch to a specific form "Main Form" from "User Form" you're on the right track. If you want to leave the "User Form" open behind the "Main Form" remove the DoCmd.Close

Use the Button Wizard to create other custom buttons.

Goh
 
If you want to avoid coding, you can use the macro builder instead. i should have said that earlier.
 
Try simply reversing the order! Open "User Form" then close your current form. You'll need to add the form name to be closed:

Code:
Private Sub Command6_Click()

Dim stDocName As String
Dim stLinkCriteria As String

On Error GoTo Err_Command6_Click


stDocName = "User Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

[B]DoCmd.Close acForm, "YourFormToBeClosed", acSaveYes[/B]


Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub

BTW, couple of housekeeping tips:

1) Always place your Dim statements at the top of a sub
2) Avoid using names with spaces: Use "UserForm" not "User Form" it'll confuse
Access less and make your life easier
 
Hi thank you for the fast replies

I will try explain better. this is what I hope to achieve

You open the database and the main menu appears.

you then click a button. the main menu then gives the impression that it "turns into" the selected form.

I never want two forms open at the same time.

My current code does this but not smoothly, you can see one form close and then the other open. I would like a more instant action like the Main Menu is transformed into the User Form.

Hope this is more clear. This forum is great
 
missinglinq said:
Try simply reversing the order! Open "User Form" then close your current form. You'll need to add the form name to be closed:

Code:
Private Sub Command6_Click()

Dim stDocName As String
Dim stLinkCriteria As String

On Error GoTo Err_Command6_Click


stDocName = "User Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

[B]DoCmd.Close acForm, "YourFormToBeClosed", acSaveYes[/B]


Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub

BTW, couple of housekeeping tips:

1) Always place your Dim statements at the top of a sub
2) Avoid using names with spaces: Use "UserForm" not "User Form" it'll confuse
Access less and make your life easier

hi sorry you must have replied while I was replying.

So in this case the form would open and then the other would close. Therefore giving the impression of the form opening much faster. Yes thats what i hoped for.

Il try this and let you know.
 
missinglinq said:
Try simply reversing the order! Open "User Form" then close your current form. You'll need to add the form name to be closed:

Code:
Private Sub Command6_Click()

Dim stDocName As String
Dim stLinkCriteria As String

On Error GoTo Err_Command6_Click


stDocName = "User Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

[B]DoCmd.Close acForm, "YourFormToBeClosed", acSaveYes[/B]


Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub

BTW, couple of housekeeping tips:

1) Always place your Dim statements at the top of a sub
2) Avoid using names with spaces: Use "UserForm" not "User Form" it'll confuse
Access less and make your life easier

Brilliant, works a charm. I think it will also be a smoother action when I have all the forms algined and sized the same.

Thank you for this and your tips.

great forum every one
 
hardhitter06 said:
If you want to avoid coding, you can use the macro builder instead. i should have said that earlier.

haha yes i would like to avoid coding but I also want to improve my coding skills.

Sadly I never got to test your method but I think it would have had a simliar process.

thanks
 

Users who are viewing this thread

Back
Top Bottom