![]() |
PROJECT PERFECT Project Management Software Specialists in Project Infrastructure |
|
|
Home - Microsoft Access Development - Microsoft Access Tips Sample Microsoft Access VBASimple FunctionsThe following are some samples of VBA code that may prove useful. Microsoft Access developers often use the same code to perform functions in many procedures. Long ago, I came to the conclusion that it was easier to build even simple MS Access functions once and get them right. Turn them into a function, strore them in a module and reuse them. Check for Blank, Null or ZeroThis is probably the one I use most in Microsoft Access VBA. It is only a few lines but has a built in error handling, and I know it works. I never have to think about it, or worry about whether it is a text field or numeric. If you have a value (say a textbox called txtName) you can check if it is blank by using: If funCheck4Nothing(Me!txtName) = True then
Check if a Form is LoadedAnother few lines that are useful if you are trying to establish if a form is actually loaded. Say the form is frmSwitchboard, you would use: If funIsLoadedForm("frmSwitchboard") Then
Is it an Access SubformThis function checks if the form is a subform. You might use this in a generic routine that does something with forms. For example, the routine might check if a user is permitted to view the form. Since the subform inherits the permissions of the main form, you may not want to check the subform. Say the subform name is frmDetails. You can use this function in the following manner. If funIsSubForm("frmDetails") = True Then
In all my applications I plug in a generic module with about 30 different functions and subroutines. I probably never use them all in one database, but they are there if I need them. It saves trying to remember how I did it before. Every developer should have a collection in a generic module. If you have any suggestions, put them on our blog for other Access Developers.
|
|---|