Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The Nz() function will handle when a type hasn't been used before and the DMax() returns Null.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  2. #17
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    This is the code that I eventually got to work:

    Me.AgencyCode = Nz(DMax("AgencyCode", "AgencyInformation", "AgencyType='Flood Only'"), 0) + 1

    Thank you all for your help.

  3. #18
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    So I have a change that needs to be made. I'm adding 1 to the previous number for 5 of the 7 choices in a combo box. This is what I have:

    Me.AgencyCode = Nz(DMax("AgencyCode", "NewAgentChecklist", "AgencyType<>'" & "Dave"' OR " & "AgencyType<>'" & "Bob"'"), 0) + 1

    Any ideas? Thanks.

  4. #19
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Maybe:

    Me.AgencyCode = Nz(DMax("AgencyCode", "NewAgentChecklist", "AgencyType<>'Dave' And AgencyType<>'Bob'"), 0) + 1

    What do you want in AgencyCode if AgencyType is "Bob" or "Dave"? What happened to "Flood Only" parameter?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #20
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It makes no sense to me to be hard-coding the criteria, but with all the unnecessary concatenation you've gotten things mixed up. Try

    Me.AgencyCode = Nz(DMax("AgencyCode", "NewAgentChecklist", "AgencyType<>'Dave' And AgencyType<>'Bob'"), 0) + 1

    Note the change from Or to And, which I think you will have found to be necessary.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #21
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    Quote Originally Posted by June7 View Post
    Maybe:

    Me.AgencyCode = Nz(DMax("AgencyCode", "NewAgentChecklist", "AgencyType<>'Dave' And AgencyType<>'Bob'"), 0) + 1

    What do you want in AgencyCode if AgencyType is "Bob" or "Dave"? What happened to "Flood Only" parameter?
    Flood Only has been upgraded to everyone but Bob and Dave. It's a real pain in the... I need the code to look at all the codes that are not Bob/Dave and take the highest one and add one to it. Dave and Bob selections will do nothing so the AgencyCode field will be entered manually.

  7. #22
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    So, I tried it, and it works. However, it only works if you click on the AgencyCode box first, then select the AgencyType. So I added thsi before the code and it runs beautifully:
    Me.AgencyCode=Dirty

    Thanks guys!

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Clueless- numerical order
    By Andy_Aus in forum Access
    Replies: 1
    Last Post: 11-28-2011, 08:49 AM
  2. design help, clueless newbie seeks help
    By victoriabitter in forum Database Design
    Replies: 3
    Last Post: 09-08-2011, 09:02 AM
  3. I am clueless
    By seast in forum Access
    Replies: 1
    Last Post: 07-15-2011, 02:51 PM
  4. Access project and im clueless
    By accessnewguy in forum Access
    Replies: 2
    Last Post: 11-30-2009, 11:53 PM

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