By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

How To Get a Command Button To do Two Functions

P: 2
Hi,
I am relatively new to Access. My question is:-
Is it possible to get a Command Button to Close one Form and to Open another Form? Would i have to use VBA to achieve this?

TIA
Colin
Nov 26 '06 #1
Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,661
Hi,
I am relatively new to Access. My question is:-
Is it possible to get a Command Button to Close one Form and to Open another Form? Would i have to use VBA to achieve this?

TIA
Colin
Command buttons are basically a link into some VBA code, so yes to that one.
With that in mind, you can do all sorts of things in VBA code (and hence off one command button) including multiple items one after the other. So that's a yes to that one too.
Nov 26 '06 #2

ADezii
Expert 5K+
P: 8,669
Hi,
I am relatively new to Access. My question is:-
Is it possible to get a Command Button to Close one Form and to Open another Form? Would i have to use VBA to achieve this?

TIA
Colin
'Here is an example of what you would like to accomplish with Error Checking included. It is activated from the Click() Event of a Command Button.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdExitForm_Click()
  2. On Error GoTo Err_cmdExitForm_Click
  3.  
  4.     'Close an Inventory Form
  5.     DoCmd.Close acForm, "frmHMAUMasterInventory", acSaveYes
  6.  
  7.     'Open an Employee Form in Edit Mode
  8.     DoCmd.OpenForm "frmEmployee", acNormal, , , acFormEdit, acWindowNormal
  9.  
  10. Exit_cmdExitForm_Click:
  11.     Exit Sub
  12.  
  13. Err_cmdExitForm_Click:
  14.     MsgBox Err.Description, vbExclamation, "Error in frmFieldInventory_Close()"
  15.     Resume Exit_cmdExitForm_Click
  16. End Sub
Nov 26 '06 #3

PEB
Expert 100+
P: 1,418
PEB
If under command button you think for the buttons from the menus in Access, so changing their meanings it's a bit hard coding...

But you can do your own command menu buttons where you can assign multiple commands

i think there was a sub like runcommand that is able to run built in commands in Access.

If you think for a button created in a form, so you can add what you want easily of course using VBA or Macro!

This is true for the both types of buttons!
Nov 26 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.