When should I use value() on cells() in vba? - ms-access

I'm trying to read and set Excel cells values with Cells(1,1). I was successful with reading this value. But I've seen code with Cells(1,1).Value(). So when should I use the notation itself: Cells(1,1) and notation with .Value() (Text()/Value2())?

The default property of Cells in VBA is Value. There's no difference in using it vs not using it.
I prefer to explicitly define the Value property though for the sake of debugging and helping others who may read my code in future as it is a clear indication of what the code is trying to achieve.

Related

PhpStorm: Can I sort properties/methods alphabetically?

Can I sort class properties and methods alphabetically.
I found that: https://plugins.jetbrains.com/plugin/9883-intellij-idea-properties-sorter
Is there any similar for PhpStorm?
First, to provide an answer to the question: Arrange your code automatically with PhpStorm (re)arranger.
To create a new rule, click the Add rule button in the upper right corner of the rules list. Configure it by type and modifier, add a name rule (like “init.*” or “*Test”) and/or set order type, if needed.
Now, in case someone is looking to sort selected text alphabetically, like I was trying to do, this might be able to help you: String Manipulation.
I wanted to select some text (like class imports in TypeScript) and order it alphabetically. I tried with the built-in code rearranger, but found it didn't work for just this simple purpose.
Source: How to sort text lines?

HTML input field dynamic "placeholder"

I have a rather stupid question, but I would like some input on the issue.
On some websites you have a date input field, which has a placeholder in the form of mm/dd/yyyy.
However, when you start typing, the characters are getting replaced one by one, like 02/3d/yyyy.
So its not a placeholder but some sort of dynamic input already. My question is, how is this generated? Is this a javascript library (jquery, angularjs etc.) or any other feature im not aware of?
Thanks for your help, I tried finding appropriate code online but nothing did the function described above.
I mean of course you could program in JS an event listener on keypress, and depending on the input you adjust the field accordingly, but I wonder if there is an easier way to do so!
You can create the mask by following this guide: https://github.com/RobinHerbots/Inputmask

Regular Expression for TextInput component: MM/DD/YY

I'm terrible with Regular Expressions but I believe in this case I must create one.
Basically, a user needs to type a date of format: MM/DD/YYYY into a TextInput and I need to verify it.
Can anyone point me in the direction of those old Flex regular expression testers that I can no longer find, please?
Thanks!
UPDATE:
Here's the regular expression just in case it'll help someone:
var pattern:RegExp = /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$/;
Grant Skinner has regexer, I think thet's what you are looking for
http://gskinner.com/RegExr/
regexpal is pretty decent too
http://regexpal.com/
\d{2}/\d{2}/\d{4} for DD/DD/DDDD
\d\d?/\d\d?/\d{4} for D/D/DDDD and DD/DD/DDDD
Rather than using regular expressions (which are perfectly fine, they can just get messy), you might consider using the Flex DateValidator or a Flex 3 DateField control. Both of these methods will make sure you end up with a valid input with little effort on your part.
There is an example of how to use each class found at the bottom of the pages I linked to.

Retrieving form value with jQuery

Sadly, this isn't as cut and dry as I had hoped. Over the past few weeks I had been researching the use of jQuery with CRM. While it's nice and dandy for style alterations, I couldn't find any examples that are closer to business logic.
For example, today I needed to alert the browser if one of 4 fields were empty. Two were date fields, one a picklist and one a checkbox (bit). I thought that calling $("#formElement").val() would have gotten the value, and in some cases it did, such as the picklist after I parsed it as an int. However, the date fields always returned an empty string.
Looking through the CRM form HTML, I see that "#formElement" isn't always the ID of an input for a CRM form element. Case in point, the date fields had ID="DateTime" (or something similar). At this point, I had thought that I will need to create a filter that will take the table that contains #formElement as it's ID and look for the value of the first input in that table, but at that point using crmForm.all.formElement.DataValue just seemed easier.
I'm sure someone here has a solution for this (and maybe some explaination of how CRM Forms are written to help with a filter), and it really stinks not being able to install add-ons for Internet Explorer here at work. Thanks for any and all help.
Use jQuery to select the form itself (either by its ID or just by $(form)) and then iterate over its children that are input text fields. I haven't done this for a form before but it might work for you.
For anyone else who is looking for an answer, I have figured it out to a managable degree. Unfortuantely, I haven't been able to use CSS selectors to shorten attribute names, but I have been able to utilize jQuery to cut down on time. If you'd like to use a CRM 4 attribute with jQuery, it looks like this:
$(crmForm.all.new_attribute).bind("click", function() { ClickFunction(); });
What I was really gunning for was chaining, because there are plenty of times when I need to null a field, disable it, and then force it to submit. A little bit of magic and this:
crmForm.all.new_attribute.DataValue = null;
crmForm.all.new_attribute.Disable = true;
crmForm.all.new_attribute.ForceSubmit = true;
Becomes:
crmForm.all.new_attribute.dataValue().disable().forceSubmit();
I hope this helps some of you guys out!

Conditional Formatting in Access 2007 Report

I have created two reports in Access 2007 that are virtually identical except for the data source. In both of them I have set up conditional formatting on a field to make the font italic when
Expression is [Status]="Holding"
In one of the reports the conditional formatting is applied and in the other it isn't. I've even tried setting it to
Expression is [Status]=[Status]
but the conditional formatting still isn't applied. Any ideas on what is going wrong?
I cleared the conditional formatting from all the text boxes where it was set. I then again set the conditional formatting to
Expression is [Status]="Holding"
This time it worked! Very strange, but at least it's working now.
I found this helpful excerpt on the Office website:
Before you begin
When you use an expression to apply conditional formatting, you should make sure that > the controls being formatted do not use the same
names as any of the fields in the form's or report's underlying record
source. If you refer to a field in an expression and there is a
control by the same name on the form or report, Access is unable to
determine whether you are referring to the control or to the field.
Because of this, Access cannot evaluate the expression. As a result,
the conditional formatting is not applied, and the control appears
with its default formatting. Whenever you add expressions to a form or
report, it is very important that you rename any controls whose names
conflict with field names that are used in the expressions.
Be also careful with the 'BackStyle' property of the control. If you use a form wizard and default style template the backstyle may be transparent - which means that conditional formatting with a backcolor does nothing.