Dlookup with 2 criteria in subform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    #1

    Dlookup with 2 criteria in subform

    I need to show a record in a txtbox in a subform from a 2nd subform in realtime.
    Table in "main" subform = RaceEntry
    Fields
    Txtbox = FinishTime
    RaceNo = (Text field)
    Racename = (Text field)

    2nd subform where data is coming from
    Table = RacetimingT
    the fields in there are
    RaceName = Text field
    RaceNumber = Textfield
    RaceFinishTime = date/time field - longtime

    I would like to bring the Racefinishtime across to the Finishtime txtbox based on the Racenumber and Racename in RacetimingT (table)
    This Racename also appears in the mainform called RacesetupF.
    this dlookup does'nt work
    in FinishTime txtbox source =DLookUp("RaceF inishTime","Rac etimingT","Race Number = '" & [RaceNo] & "' And [Racename] = '" & Me.RaceName & "'")

    pls help
    Last edited by neelsfer; Nov 8 '10, 08:54 PM. Reason: changed fields
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Reading the Current Record in the Sub-Form:
    Code:
    =DLookUp("RaceFinishTime","RacetimingT","RaceNumber = '" & _
              Forms!<Form Name>!<Sub-Form Name>.Form![RaceNo] & "' And [Racename] = '" & _
              Forms!<Form Name>!<Sub-Form Name>.Form![RaceName] & "'")

    Comment

    • neelsfer
      Contributor
      • Oct 2010
      • 547

      #3
      Thx for quick reply
      i tried this, does not seem to work
      =DLookUp("RaceF inishTime","Rac etimingT","Race Number = '" & [Forms]![RaceSetupF]![EntryDetailsSF].[Form]![RaceNo] & "' And [Racename] = '" & [Forms]![RaceSetupF]![EntryDetailsSF].[Form]![RaceName] & "'")
      just want to confirm
      The mainform is called RaceSetupF; the subform where txtbox is that require the Racefinishtime, is called "EntryDetailsSF " and the subform where the data comes from is called "Racetiming SF". All fields are txtfields
      thx so far

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Code:
        =DLookUp("RaceFinishTime","RacetimingT","RaceNumber = '" & _
                  Forms!RaceSetupF!RacetimingSF.Form![RaceNo] & "' And [Racename] = '" & _
                  Forms!RaceSetupF!RacetimingSF.Form![RaceName] & "'")

        Comment

        • neelsfer
          Contributor
          • Oct 2010
          • 547

          #5
          Hi
          ADezii
          May i send you the file to help pls?
          its 270kb zipped
          thx
          Neels

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            I already sent you a Private Message listing my E-Mail Address.

            Comment

            • neelsfer
              Contributor
              • Oct 2010
              • 547

              #7
              I made a mistake the. "Racename" field in the subform where the txtbox is to be filled with the dlookup is a numberfield while the other one is a txtfield. I am therefore changing the criteria to "racedate" to make it the same in both tables.
              to summarise again
              Main form is called "RaceSetupF "
              Table in "main" subform is called RaceEntry and the subform there is called "NoFinished SF"
              Fields
              Txtbox = FTime
              RaceNo = (Text field)
              Racedate = (date field)

              The subform from where the data comes is called "RaceTiming SF" " and the table is called "Racetiming T"
              fields are
              RaceDate = date field
              RaceNumber = Textfield
              RaceFinishTime = date/time field - longtime
              I tried this without success in controlsource of the "Ftime" txtbox
              =DLookUp("RaceF inishTime","Rac etimingT","Race Number = '" & Forms!RaceSetup F!RacetimingSF. Form!RaceNo & "' And [Racedate] = #" & Forms!RaceSetup F!RacetimingSF. Form!RaceDate & "#")What i need it to do is that the RacefinishTime must be Racedate dependant. Ie different "Racedates" may have the same RaceNo/Racenumber and i need to distinguish then based on the date. for example you may have a RaceNo = 1 on two different dates for which i need a Racefinishtime per that RaceNo .
              pls help

              Comment

              • ADezii
                Recognized Expert Expert
                • Apr 2006
                • 8834

                #8
                Looks like it may be a Typo in the Race Number Field in the Sub-Form, it is [RaceNumber] and NOT [RaceNo]:
                Code:
                =DLookUp("RaceFinishTime","RacetimingT","RaceNumber = '" & [Forms]![RaceSetupF]![RacetimingSF].[Form]![RaceNumber] & "' And  [Racedate] = #" & [Forms]![RaceSetupF]![RacetimingSF].[Form]![RaceDate] & "#")

                Comment

                Working...