Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2005

Tip: Looking for answers? Try searching our database.

Counting on Demand (Dmax)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pat Zoch - 18 Jul 2005 08:32 GMT
I've read thru countless threads, but I can't seem to get my code to work.  
My office handle hundreds of correspondence, only some of which get filed.  
While I can easily use autonumber for each piece of paper that come thru, I
need a meaningful number for my file system that is sequential.  I've tried
the following code, but it does not work.  Can someone offer some advice?

My table is "Correspondence".  The Form is "Correspondence Log."  The cell
which stores the file numbers is "File#".  I've called my toggle button
"Assign File#" which also stores a flag in a cell called "Filed"

If IsNull (File#) = True Then File# = Dmax("[File#]", "Correspondence") +1

I've tried this code in both before and after update.  I've also tried it
using If File# = "0" which tends to pop up in the field despite the null
default.

Any suggestions?
Wolfgang Kais - 18 Jul 2005 10:07 GMT
Hello Pat.

[...]
> If IsNull (File#) = True Then File# = Dmax("[File#]", "Correspondence") +1
>
[quoted text clipped - 3 lines]
>
> Any suggestions?

How about:
If IsNull([File#]) Then [File#] = Dmax("[File#]", "Correspondence") +1
The # is the type specifier for "double". Your code is therefore looking for
a variable named File of type double.
To avoid this kind of error, make the variable declaration mandatory (Tools,
Options). This will insert "Option Explicit" in all new modules.

Signature

Regards,
Wolfgang

Pat Zoch - 18 Jul 2005 13:22 GMT
Wolfgang,

The sound you hear is me celebrating.  Thank you very much.  It works
perfectly.

Pat

> Hello Pat.
>
[quoted text clipped - 13 lines]
> To avoid this kind of error, make the variable declaration mandatory (Tools,
> Options). This will insert "Option Explicit" in all new modules.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.