Results 1 to 5 of 5
  1. #1
    undee69 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    39

    How to format a "Number" Data type

    Hi everyone,



    I am trying to format my Number data type to look like this: 0001 / 2013 where "0000" is the prefix, 1 is the number and " / 2013" is the suffix.

    Tablename: tblclients
    Field Name: DelNoteNo
    Data type: Number

    Form
    Control Name: DelNoteNo
    Control Source: DelNoteNo

    I am searching on this forum but I can't get it working.

    On the Before Up date procedure i have:

    DelNoteNo = Nz(DMax(DelNoteNo, "tblClients"), 0) +1

    but its is giving "invalid use of Null "

    What am I missing?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The field name needs to be in quotes in the DMax.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    undee69 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    39
    I am using the code below

    Private Sub DelNoteNo_BeforeUpdate(Cancel As Integer)

    DelNoteNo = Nz(DMax("DelNoteNo", "tblClients"), 0) + 1

    End Sub

    but when I try to enter 1 or any number, it gives me the error :

    Run-time error '-2147352567 (80020009):

    The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Access from saving the data in the field.

  4. #4
    undee69 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    39
    What I want it to achieve is for it to show the following series as my "DelNoteNo"

    0001
    0002
    0003
    .
    .
    .
    0010
    0011
    .
    .
    .
    0100

    is this possible?

  5. #5
    undee69 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    39
    I solved it myself ^_^

    DelNoteNo Table Properties
    Format: \000" / 2013"

    DelNoteNo Control Properties
    Format: \000" / 2013"
    Default Value: =Nz(DMax("DelNoteNo","tblClients"),0)+1

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 08-23-2012, 08:32 AM
  2. Replies: 1
    Last Post: 08-05-2011, 12:05 PM
  3. Replies: 2
    Last Post: 05-17-2011, 02:40 PM
  4. Replies: 21
    Last Post: 06-03-2009, 05:54 PM
  5. aSTR = Dir("C:\*.*") >> "Type Mismatch"
    By JGrant in forum Programming
    Replies: 1
    Last Post: 03-28-2009, 05:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums