Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Dlookup question

Discussion in 'Information Technology' started by JOM, Nov 10, 2005.

  1. JOM

    JOM
    Expand Collapse
    Guest

    can you use dlookup to find more than 1 item from a table e.g.,
    dlookup("Field1","field2",[tblName],field 1=0)
     
  2. Loading...

    Similar Threads Forum Date
    Anyone Have Any Unanswered Questions On Sikhi Or God? Sikh Sikhi Sikhism Jan 7, 2017
    Question About Translations Questions and Answers Dec 20, 2016
    Question About GGS Questions and Answers Aug 28, 2016
    Marriage And Discrimination Related Questions Blogs Mar 21, 2016
    Sikhi Questioning Faith Sikh Sikhi Sikhism Mar 3, 2016

  3. OP
    Ofer

    Ofer
    Expand Collapse
    Guest

    No, you'll need to open a RecordSet

    --
    The next line is only relevant to Microsoft''s web-based interface users.
    If I answered your question, please mark it as an answer. It''s useful to
    know that my answer was helpful
    HTH, good luck


    "JOM" wrote:

    > can you use dlookup to find more than 1 item from a table e.g.,
    > dlookup("Field1","field2",[tblName],field 1=0)
    >
     
  4. OP
    Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    Sort of.

    DLookup will only return a single value, but you can have it concatenate
    fields together. For example, you could have it return field1 and field2
    separated by a comma, and then split the values apart afterwards.

    Dim strField1 As String
    Dim strField2 As String
    Dim strReturn As String

    strReturn = DLookup("[Field1] & ',' & [Field2]", _
    "[tblName]", "[Field1] = 0")

    strField1 = Left(strReturn, InStr(strReturn, ",") - 1)
    strField2 = Mid(strReturn, InStr(strReturn, ",") + 1)

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)



    "JOM" <JOM@discussions.microsoft.com> wrote in message
    news:A2AA7392-01E0-4CB9-91F9-F93340F35504@microsoft.com...
    > can you use dlookup to find more than 1 item from a table e.g.,
    > dlookup("Field1","field2",[tblName],field 1=0)
    >
     
  5. OP
    Ofer

    Ofer
    Expand Collapse
    Guest

    Amaizing, I had no Idea.
    So you can actually return unlimited amount of fields

    Dim strField1 As String
    Dim strField2 As String
    Dim strField3 As String
    Dim strReturn As String

    strReturn = DLookup("[Field1] & ',' & [Field2] & ',' & [Field3]", _
    "[tblName]", "[Field1] = 0")

    strField1 = split(strReturn ,",")(0)
    strField2 = split(strReturn ,",")(1)
    strField3 = split(strReturn ,",")(2)

    Thank you, Douglas

    "Douglas J. Steele" wrote:

    > Sort of.
    >
    > DLookup will only return a single value, but you can have it concatenate
    > fields together. For example, you could have it return field1 and field2
    > separated by a comma, and then split the values apart afterwards.
    >
    > Dim strField1 As String
    > Dim strField2 As String
    > Dim strReturn As String
    >
    > strReturn = DLookup("[Field1] & ',' & [Field2]", _
    > "[tblName]", "[Field1] = 0")
    >
    > strField1 = Left(strReturn, InStr(strReturn, ",") - 1)
    > strField2 = Mid(strReturn, InStr(strReturn, ",") + 1)
    >
    > --
    > Doug Steele, Microsoft Access MVP
    > http://I.Am/DougSteele
    > (no e-mails, please!)
    >
    >
    >
    > "JOM" <JOM@discussions.microsoft.com> wrote in message
    > news:A2AA7392-01E0-4CB9-91F9-F93340F35504@microsoft.com...
    > > can you use dlookup to find more than 1 item from a table e.g.,
    > > dlookup("Field1","field2",[tblName],field 1=0)
    > >

    >
    >
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page