Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65

    Clueless query


    Just trying to noob my way through creating a DB. Here's what I wanna do in Computer-English...

    IF you selected Party from the drop down list
    THEN run a query that looks up party records and takes the max
    Then add 1 to the max and put that number in PartyCode

    I started writing it in VBA but couldn't figure out how to do it without opening a query.

  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
    Try DMax() using the drop down in the criteria:

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    Look like this:
    Me.PartyCode=DMax("PartyCode" , "Party" , "BestParties")+1
    assuming BestPArties was the type of party I wanted to add 1 to?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Did you look at the link?

    DMax("PartyCode", "Party", "PartyType = '" & Forms!FormName!ComboName & "'")

    replacing the items in red with their actual names
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    I did but it's hard for me to understand this sometimes because I'm not studying liberally. I'm looking up topics to find solutions to my problems. All I need to do is make this one DB and that's it. The ! Is new to me. I will try it again Friday and see how it goes.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The bang (!) should work but if you want intellisense popup help, use dot (.).
    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.

  7. #7
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    This, !, is a factorial in the math field. So I'm not familiar with ! Vs. .

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Just type them in code as suggested and see what happens.
    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.

  9. #9
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    Is it necessary to use the 3rd criteria for DMax if I use an If/then statement for the choice of the drop down?

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I don't understand, but without a criteria you'll get the max value regardless of the type of party.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Use an If/Then where and how will that filter records?

    Without the criteria, DMax will return the maximum value in the table, not the maximum value of the selected party type records.
    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.

  12. #12
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    What I have:

    If (Me.AgencyCode = "Flood Only") Then
    Me.AgencyCode = DMax("AgencyCode", "Agency Information", "AgencyType=FloodOnly"' &Forms!AgencyInformation!AgencyType & '") + 1
    End If

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The placement of apostrophes is wrong.

    Why do you have the literal text "FloodOnly" in the criteria?

    Me.AgencyCode = Nz(DMax("AgencyCode", "Agency Information", "AgencyType='FloodOnly" & Forms!AgencyInformation!AgencyType & "'"),0) + 1
    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.

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    Me.AgencyCode = DMax("AgencyCode", "Agency Information", "AgencyType='" & Forms!AgencyInformation!AgencyType & "'") + 1
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    QuantifyRisk is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    65
    Quote Originally Posted by June7 View Post
    The placement of apostrophes is wrong.

    Why do you have the literal text "FloodOnly" in the criteria?

    Me.AgencyCode = Nz(DMax("AgencyCode", "Agency Information", "AgencyType='FloodOnly" & Forms!AgencyInformation!AgencyType & "'"),0) + 1
    What is Nz for?

Page 1 of 2 12 LastLast
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