Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513

    simple syntax problem

    trying to return the record where:
    txtType = me.txtType (there will most likely be several records)
    and
    that record (of those that match) that has the lowest value for the field lngPrintOrder

    strSearch = "[txtType] = '" & Me.txtType & "'" <--- works!

    strSearch = "[txtType] = '" & Me.txtType & "' and [lngPrintOrder] = min([lngPrintOrder])" <--- this does NOT !

    with thanks in advance,


    Mark

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Dmin("[field]", "table")

    strSearch = "[txtType] = '" & Me.txtType & "' and [lngPrintOrder] =" & Dmin("[field]", "table")

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    What exactly is lngPrintOrder?

    strSearch = "[txtType] = '" & Me.txtType & "' and [lngPrintOrder] = min([lngPrintOrder])"

    needs to be something such as

    strSearch = "[txtType] = '" & Me.txtType & "' and [lngPrintOrder] =" & min([lngPrintOrder])

    The stuff in purple has to be rendered to a value, then substituted into the expression. So it can not be in quotes


    min will not be recognized. We need some context for what lngPrintOrder means and where it gets populated and which values you need for your search.

    Update: As Ranman has posted, DMin() could be the answer.

  4. #4
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513
    within table tblPages are fields:
    txtType - string
    lngPrintOrder - long number
    PageLink - hyperlink

    this table is linked in a many-to-one relationship to another table where the relationship is thru txtType
    so there may be many txtTypes in tblPages, and I am looking for the first page of txtType...

    Ranman256's DMin() almost works, but it yields the lowest value for lngPrint Order in the table;
    what I need is the lowest lngPrintOrder where among the records where txtType = me.txtType

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    lngPrintOrder is not a unique identifier in the table?

    strSearch = "txtType='" & Me.txtType & "' AND lngPrintOrder=" & DMin("lngPrintOrder", "tblPages", "txtType='" & Me.txtType & "'")
    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.

  6. #6
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513
    (for very curious reasons... lngPrintOrder is not a unique identifier)

    never-the-less,
    your syntax is exactly right

    big thnx
    new lesson learned!

    mark

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

Similar Threads

  1. simple boolean syntax ?
    By markjkubicki in forum Forms
    Replies: 3
    Last Post: 03-05-2013, 06:26 PM
  2. simple syntax ?
    By markjkubicki in forum Queries
    Replies: 2
    Last Post: 10-09-2012, 10:31 AM
  3. simple SQL syntax with hyperlink
    By markjkubicki in forum Programming
    Replies: 2
    Last Post: 01-18-2012, 06:58 PM
  4. Simple Syntax Help
    By cvegas in forum Programming
    Replies: 7
    Last Post: 04-20-2011, 01:46 PM
  5. simple syntax question
    By markjkubicki in forum Programming
    Replies: 6
    Last Post: 09-14-2010, 04:13 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