Question MS Access Templates and Understanding them

mcclunyboy

Registered User.
Local time
Today, 14:51
Joined
Sep 8, 2009
Messages
292
Hi,

I am trying to learn MS Access - I am using MS Templates to try and figure out how things work. I know a bit already but I keep coming across things which I can't explain:

What do these do:

Where condition of a searchforrecord command in a macro
="[ID]=" & Nz(DMax("[ID]",[Form].[RecordSource]),0)

Where condition of an open form command in a macro:
1=0

Will have more when I keep looking around...
 
boy,

DO NOT LEARN ACCESS FROM MICROSOFT EXAMPLES. that's like taking a theory course. if you're gonna be a professor, fine, but if not, surround yourselves with human beings that have done it and drop the books.
 
ok but what does the "Nz" part do, I keep coming across it and it is bugging me
 
Nz (short for Nulls) will return a default value if the item you are looking for, or calculating doesn't return anything. if you're looking up a number and the number isn't found, Nz will return zero. if you're looking for a string and don't get one, Nz will return and empty string (""). so, you will always have something to work with. when the lookup or calculation is finished you can check on the returned value. if it's zero, or "" or some other default value, you know you didn't get what you were looking for and can take appropriate action.
 
ok but what does the "Nz" part do, I keep coming across it and it is bugging me

NZ is "Null to Zero" and you can, as Wazz said, assign what you want returned if a null is encountered. The defaults are 0 for any numerics and "" (empty string) for any strings, and 0 for any dates (which means 12/31/1899).
 
Oh, and almost forgot - the Templates from Microsoft do not necessarily showcase best practices. As a matter of fact, they sometimes display WORST practices (like lookup fields at table level, names with spaces or special characters in them, the use of Access Reserved Words such as NAME for field or object names, Old outdated use of DoMenuItem code, and more).

So, some of it is good for learning but there is also a lot of questionable material there. They have made some strides in improving but there are still some not so good things there as well.
 
...you can, as Wazz said, assign what you want returned if a null is encountered.
right, i wasn't really complete there. you can let the Nz function return a default automatically if you want, but you can also supply a value if Null is about to be returned.
 

Users who are viewing this thread

Back
Top Bottom