Results 1 to 11 of 11

Thread: Need help creating an increment field VBA

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    Need help creating an increment field VBA

    I need to create a field named “casenumber” that will contain increment number value for each record (similar to “AutoNumber”) but I need it to reset to 0001 at the first of each month. I am using Access 2000.

    Thanks in advance

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Need help creating an increment field VBA

    No idea why you'd want to reset it.




    Make a table of one row and one column. Put your number in there. When saving the new record, get the number from this table, increment it and update that then create your new record with the number you retrieved.

    Then every month you can change the number back to 0... or 1...

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    Re: Need help creating an increment field VBA

    This field is used in a database that tracks criminal offences on a monthly basis. Each occurrence is identified by a “case number” which is broken down as follows: 06-03-0001 .06 = Year 03 = Month 0001 represents the individual criminal activity for that time period.

    Again thanks for any help

    carbo

  4. #4
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Need help creating an increment field VBA

    I don't have time to work on this right now, but one approach is to set up a Global variable for the Item Sequence number (case number) and a Global Boolean flag "gb_Updated".

    Set up a macro that runs when the workbook opens. This is NOT code ... it is just what I wold have the macro do:

    If (day of month) > 15 then gb_Updated = False

    if (day of month <= 15) AND (gb_Updated = False) then
    gi_CaseNum = 1
    gb_Updated = True

    Are you guaranteed to have at least ONE case during the first half of the month? This will update the Case Number only One Time anytime during the first half of the month (it doesn't have to be on the very first day of the month!). Can you take it from here? If not, I'll post more Wednesday.
    Last edited by Webtest; Mar 6th, 2006 at 04:12 PM.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    Re: Need help creating an increment field VBA

    Typically there are from 800-1500 entries per month.

    Thanks

    carbo

  6. #6
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: Need help creating an increment field VBA

    Hi,

    How many criminal offenses do you process every month? Are you creating a program for a trial court?Prison?

    Thanks....
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    Re: Need help creating an increment field VBA

    This MsAccess 2000 database is for a 911 Center that assigns case numbers to various law enforcement agencies as well as other emergency services type disciplines. It is a centralized repository for “Master Name Index” information.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need help creating an increment field VBA

    I would recommend that you get them off of Acccess then as its not really scallable enough and is subject to corruption issues if your not careful in its design and code access.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    Re: Need help creating an increment field VBA

    Would it be your assertion that a MsAccess database, created in a “flat file” format, be equally susceptible to corruption as a “relational” format?
    Last edited by carbo; Mar 7th, 2006 at 08:22 PM.

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need help creating an increment field VBA

    A flat file would be stable but it is also a nightmare to manage.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    Re: Need help creating an increment field VBA

    I still have not resolved this issue; any and all help will be greatly appreciated.

    Thanks

    Carbo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width