Results 1 to 13 of 13
  1. #1
    Macgyver1234 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    7

    Form help.

    Hello

    I'm a basic beginner and do not know much about Access.

    What I need help with is quite basic for you guys.

    1st. On my form there is a invoice label. I would like the invoice to update it self rather than me checking the invoice table and typing the next invoice number.
    I used a number of beforeupdate:=dmax yadaydayda.
    I must have copied them in wrong so I need help on what I'm meant to enter in.

    2nd. When entering information in the form I would like if it told me if I missed something, such as I didn't enter info for P.O number.
    I would like if it told me this if I was about to make a new record but left something out in the current one.

  2. #2
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    Macgyver1234,

    Are you using auto-numbering as your primary key?

    If you are then this is the way to automatically add a number for each new invoice. (see attached file)

    The format is 2003, I don't have 2007.

    Your second part of the question; you can use the "Tag" property of the control on your form. Have a look under TAG in help.

    If you need further help then post back.

  3. #3
    Macgyver1234 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    7
    Thanks for reply ansentry.

    I could use autonumbering, but rather leave the database as it is, as everything has been set up well.
    If this is the only way it can be done then I will do it.

  4. #4
    Macgyver1234 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    7
    Alright never mind.
    I made a backup and changed the invoices to auto numbers.
    Its working fine.

    Thanks mate.


    Just wondering.
    When I make a invoice say 00014 and I delete it, if I make a new invoice it will show up with 00015.
    Is 00014 taken for ever?

  5. #5
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    Have you read the code that creates the new number?
    It look for the current maximum number then adds 1. If your last number used was 0014 and then you delete it then your new max number is 0013, so 0013 + 1 and the new number would be 0014.

  6. #6
    Macgyver1234 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    7
    How do I find the code for it?
    I can't find it in Access 2007.

  7. #7
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    The code is behind the form which is in the sample db I sent you.

    Open the form in design view and then use Alt-F11 and you will see it.

  8. #8
    Macgyver1234 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    7
    Hmm this is strange. When I open your Access form in the code page I get plenty of code and can select labels and such.
    But when I open mine up, nothing is listed to choose from....

    why?

  9. #9
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    I don't have access 2007 so I'm not much help.

  10. #10
    SteveH2508 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Chelsea, London, England
    Posts
    117
    Quote Originally Posted by Macgyver1234 View Post
    Hmm this is strange. When I open your Access form in the code page I get plenty of code and can select labels and such.
    But when I open mine up, nothing is listed to choose from....

    why?
    Make sure your database is in a Trusted Location.

  11. #11
    Macgyver1234 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    7
    Quote Originally Posted by SteveH2508 View Post
    Make sure your database is in a Trusted Location.
    I open the file in the same location where the number file was(there poster above gave me).

    Still won't show me code.

    Why is this happening?

  12. #12
    Macgyver1234 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    7
    Any one?
    It seems really basic, if only I could see the code.

  13. #13
    SteveH2508 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Chelsea, London, England
    Posts
    117
    Code:
    Option Compare Database
    Option Explicit
    Private Sub Form_Current()
    Me.txtCusID.Enabled = False
    Me.txtCusNumber.Enabled = False
    Dim iNumber As Integer
    iNumber = Nz(DMax("[CusNumber]", "tblCustomer"), 0)
    If Me.NewRecord = True Then
    Me.txtCusNumber = iNumber + 1
    End If
    Exit Sub
    End Sub
     
    Private Sub cmdNewRecord_Click()
    On Error GoTo Err_cmdNewRecord_Click
    DoCmd.GoToRecord , , acNewRec
    Exit_cmdNewRecord_Click:
    Exit Sub
    Err_cmdNewRecord_Click:
    MsgBox Err.Description
    Resume Exit_cmdNewRecord_Click
    End Sub
    This is the code.

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

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