![]() | |
![]() |
| | Thread Tools | Display Modes |
#21
| |||
| |||
|
|
What is a function expression? I have started to write some modules/classes to do some things in that great book. -paulw |
#22
| |||||
| |||||
|
|
"PW" wrote in message news:a70lg7dri2vbh79vhdimmi6meih5escuan (AT) 4ax (DOT) com... What is a function expression? I have started to write some modules/classes to do some things in that great book. -paulw By function expression I mean standard Access functions. In the sql builder, or even for properties sheets in Access, or even with a text box control on a form, you can use a function name. =TodayTimeAndDate() So the above is a function expression you could place in a text box. So the above would display the results of the function. Access has what is called a "expression" service. So in a standard code module: Public Function TodayTimeAndDate() as string TodayTimeAndDate = "The current date and time time is " & Now() End function. When you build the XML if you specify the call back the standard way, it will look like this: button id="Tab1" label="TestButton" imageMso="ViewsFormView" size="large" onAction="PrintInvoice" / In the above, PrintInvoice MUST be a Sub defined in a standard code module. It cannot be code in your current form. However, if I use a expression, then we get this: button id="Test1" label="TestButton" imageMso="ViewsFormView" size="large" onAction="=PrintInvoice()" / Note the use of = and (). Now just like any expression in Access, the function will be called. |
|
This allows and means the public function can be placed in your form where it often belongs. So for things like a button that prints a report or even EXISTING button code on your form, you can have both buttons and ribbon code call/use the same code (very handy as you migrate buttons from a form up to a ribbon). |
|
And you can also pass parameters in the above. So 3 ribbon buttons to print 3 reports could use this: button id="report1" label="Customer Report" imageMso="ViewsFormView" size="large" onAction="=MyReport('rptCustomers')" / button id="report2" label="Sales Report" imageMso="ViewsFormView" size="large" onAction="=MyReport('rptSales')" / button id="report3" label="Phone listing" imageMso="ViewsFormView" size="large" onAction="=MyReport('rptPhonelist')" / Now in that form code module, you simple write this code: Public Function MyReport(strReport as string) docmd.OpenForm strReport, acviewPreview End function So this is not a call back, but an expression. I mean you could even call a msgbox like this: button id="report3" label="msgbox test" imageMso="ViewsFormView" size="large" onAction="=msgbox('hello world')" / The above would thus use the msgbox box function direct in the ribbon xml. So for most cases, I VERY much recommend you use a function expression and NOT use callbacks. I have no idea why books, or this idea not been more wide shared in public - I just lack the time to write up and post an article on this issue. As noted, this also allows with great ease to use the same ribbon for more then on form. |
|
What ever form has the FOCUS is where the public functions will be run FROM that current forms code module. So you can create a public function called "myDelete" for all your forms that assumes and has the VBA delete code (same code you might have on a delete button on that particular form). Now the one ribbon will work for all those forms no matter what since the custom MyDelete() function in the given form that has focus is the code that will run when you click on the ribbon button. |
|
I consider the above tip a near breakthrough in terms of ease and time it saves in regards to writing ribbon code. |
#23
| |||
| |||
|
|
If Access was object orientated, |
#24
| ||||||
| ||||||
|
|
Note the use of = and (). Now just like any expression in Access, the function will be called. I don't think I get why doing it this way is any different than what I am already doing to run a form: |
|
This allows and means the public function can be placed in your form where it OFTEN belongs. |
|
Sounds like I will have to duplicate code in each form |
|
Idon't know why I would want to take buttons from a form and put them on a ribbon (at least not yet). |
|
I think I see where you are going with this, but all our forms already have a "delete" button (for example) with code. |
#25
| |||
| |||
|
#26
| |||
| |||
|
#27
| |||
| |||
|
|
Maybe too late for me to ask a silly question Albert (or anyone), but all this ribbon stuff that I have been doing will work with a runtime version, correct? The print ribbon etc... right? Code like this: |
#28
| |||
| |||
|
|
Take a look at this Access screen shot to see what I mean: http://fairsoftware.com/images/speci...rs-entries.png Or this one: http://fairsoftware.com/images/speci...mizelayout.png In fact take a look at these Access screens here: http://fairsoftware.com/screenshots.aspx In all of the above cases, you can see the buttons have been removed from the forms and placed in the ribbon. The above are Access forms and they look rather nice. |
#29
| |||
| |||
|
|
In fact take a look at these Access screens here: http://fairsoftware.com/screenshots.aspx In all of the above cases, you can see the buttons have been removed from the forms and placed in the ribbon. The above are Access forms and they look rather nice. Albert, why do you think this is a good user interface???? I find it awkward and a challenge to use (from looking at the screenshot). Sure, it's "pretty". If I find it a burden to use, then our clients most doubt will!! I am not just referring to the ribbon, but the diagram form and the rest of it on the right. Why are both there???? |
#30
| |||
| |||
|
|
"PW" wrote in message news:56gpi75djgde6j1qnm9mqg92qs1sfmp9ar (AT) 4ax (DOT) com... In fact take a look at these Access screens here: http://fairsoftware.com/screenshots.aspx In all of the above cases, you can see the buttons have been removed from the forms and placed in the ribbon. The above are Access forms and they look rather nice. Albert, why do you think this is a good user interface???? I find it awkward and a challenge to use (from looking at the screenshot). Sure, it's "pretty". If I find it a burden to use, then our clients most doubt will!! I am not just referring to the ribbon, but the diagram form and the rest of it on the right. Why are both there???? First, I think the forms are rather nice to look at. But, I am not sure which one you refer to when you say "diagram" form? I mean, no doubt that lots of UI going to be preferences etc, and some is going to be just downright usability (or lack of), but I dare say that software, even from great companies like Acronis disk tools again shows this trend: http://bilder.egmont.se/cache/47/473...45e01ac3c6c1d5 |
|
So, I just pointing out we see a trend towards more web like and also that of more "touch" friendly UI. In fact we seeing the ribbon lends VERY well to tablet and touch based UI where as cascading menu bars work VERY poorly on tablets. |
![]() |
| Thread Tools | |
| Display Modes | |
| |