In an earlier article, I discussed the problems associated with FastForms date fields. I suggested using regular text boxes at that time, but what if you want to make them act like M2M date fields with the double click feature? In case you don’t know, when you double click a date field in M2M it automatically enters the current date.
Well, you would use VBA code to perform mimic that for your FastForms text box. How do you program that event? Well, the code would look something like this, but for the sake of simplicity, I’ll just pop-up a message box with “Hello World” instead.
Public Function m2mpageframe1_page1_txttest_DBLCLICK() As Boolean MsgBox ("Hello World") m2mpageframe1_page1_txttest_DBLCLICK = True End Function
Now you will notice that there is no ctlTarget container involved, I have no idea why. As I mentioned before, FastForms can be inconsistent. However, this does not work, and it didn’t work when I added ctlTarget either.
So, how can it be made to work? Well, there are two ways to use code with FastForms. You can place it in your M2VEvents.prj file, or you can place that code directly inside the FastForms controls. I prefer the first option when it works.
You can place code inside the FastForms controls instead of in the VBA project file.
Here is where the trick comes in. In the above picture, you will notice that I put a piece of comment code into the double click property of the FastForms control. When you do so, the code inside the control will activate, but your VBA code in the VBA project file will run as well. After doing so, I got the following:
Cute trick huh? I originally discovered this on the Purchase Order (PO) Screen, but I have since tested it on other screens and it seems to work on all of them.