![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I want to have the usual save, edit, new, etc.. buttons on the ribbon instead of on each form. How would I go about that? And, I need to run an different form edit routine for each form as the control names will be different,.... -paulw |
#3
| |||
| |||
|
|
"PW" wrote in message news:ug8vs7pg98ghh366aubr1tnvsh255hgc7i (AT) 4ax (DOT) com... Hi, I want to have the usual save, edit, new, etc.. buttons on the ribbon instead of on each form. How would I go about that? And, I need to run an different form edit routine for each form as the control names will be different,.... -paulw The simple solution here is to not use a a call back routine. Simply place the functions as public in each form. The form with the focus will thus run. So the on-action of the ribbon would be: =MyPublicFunctionName() Note CAREFULLY how we have = and () (you must have these), and they must be under the quotes. Eg for the xml we have: onAction="=MyDelete()" So a public function called MyEdit would be local to each form. This allows the use of "me", means the code is in each form so the code can deal with different field names etc. So using public functions in place of a SUB with call backs not only solves your problem of one ribbon running different code depending on what form has the focus but such an approach also means that the code for each form can be placed in each form and not have to be a public SUB in a standard code modules like a ribbon call back. Note you can also pass values from the ribbon if you wanted. So a ribbon with a bunch of buttons to launch a report would look like: And note that the public does not have to be placed in the form and thus functions in standard code modules become global (forms are searched first, and if function not found then the public code modules are searched). So for a few buttons on a ribbon to launch/display reports we create a public function in standard code module: Public Function MyOpenReport(strR As String) DoCmd.OpenReport strR, acViewPreview End Function Then XML for ribbon would be: onAction="=MyOpenReport('rptDailySalesTotal')" Note how I used single quotes to pass the report name. So for above this means for each button you place on the ribbon you don't have to write any additional VBA code to launch a report. -- Albert D. Kallal (Access MVP) Edmonton, Alberta Canada PleaseNoSpam_kallal (AT) msn (DOT) com |
#4
| |||
| |||
|
|
"PW" wrote in message news:ug8vs7pg98ghh366aubr1tnvsh255hgc7i (AT) 4ax (DOT) com... Hi, I want to have the usual save, edit, new, etc.. buttons on the ribbon instead of on each form. How would I go about that? And, I need to run an different form edit routine for each form as the control names will be different,.... -paulw The simple solution here is to not use a a call back routine. Simply place the functions as public in each form. The form with the focus will thus run. So the on-action of the ribbon would be: =MyPublicFunctionName() Note CAREFULLY how we have = and () (you must have these), and they must be under the quotes. Eg for the xml we have: onAction="=MyDelete()" So a public function called MyEdit would be local to each form. This allows the use of "me", means the code is in each form so the code can deal with different field names etc. So using public functions in place of a SUB with call backs not only solves your problem of one ribbon running different code depending on what form has the focus but such an approach also means that the code for each form can be placed in each form and not have to be a public SUB in a standard code modules like a ribbon call back. Note you can also pass values from the ribbon if you wanted. So a ribbon with a bunch of buttons to launch a report would look like: And note that the public does not have to be placed in the form and thus functions in standard code modules become global (forms are searched first, and if function not found then the public code modules are searched). So for a few buttons on a ribbon to launch/display reports we create a public function in standard code module: Public Function MyOpenReport(strR As String) DoCmd.OpenReport strR, acViewPreview End Function Then XML for ribbon would be: onAction="=MyOpenReport('rptDailySalesTotal')" Note how I used single quotes to pass the report name. So for above this means for each button you place on the ribbon you don't have to write any additional VBA code to launch a report. -- Albert D. Kallal (Access MVP) Edmonton, Alberta Canada PleaseNoSpam_kallal (AT) msn (DOT) com |
![]() |
| Thread Tools | |
| Display Modes | |
| |