Double code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lars

    Double code

    In this code Dmax is executed twice (when all is well). How can I make it so
    that I only have to put de DMAX line one time in the code? Hope this is
    clear.

    Dim d as Date

    If IsNull(DMax("[Date_request]", "tblRequest ", "[Sender] = """ &
    Forms![fTest]![Sender] & """")) Then
    Exit Sub
    Else
    d = DMax("[Datum_request]", "tblRequest ", "[Sender] = """ &
    Forms![fTest]![Sender] & """")
    endif

    Thank you very much for any help.

    Lars Brownie


  • Lars

    #2
    Re: Double code

    Got it. I found that the variant tye variable can hold null values.

    "Lars" <lars@brownie.c omschreef in bericht
    news:frimh8$tbe $1@textnews.wan adoo.nl...
    In this code Dmax is executed twice (when all is well). How can I make it
    so that I only have to put de DMAX line one time in the code? Hope this is
    clear.
    >
    Dim d as Date
    >
    If IsNull(DMax("[Date_request]", "tblRequest ", "[Sender] = """ &
    Forms![fTest]![Sender] & """")) Then
    Exit Sub
    Else
    d = DMax("[Datum_request]", "tblRequest ", "[Sender] = """ &
    Forms![fTest]![Sender] & """")
    endif
    >
    Thank you very much for any help.
    >
    Lars Brownie
    >

    Comment

    • Benny Andersen

      #3
      Re: Double code

      On 16 Mar., 09:42, "Lars" <l...@brownie.c omwrote:
      In this code Dmax is executed twice (when all is well). How can I make it so
      that I only have to put de DMAX line one time in the code? Hope this is
      clear.
      >
      Dim d as Date
      >
      If IsNull(DMax("[Date_request]", "tblRequest ", "[Sender] = """ &
      Forms![fTest]![Sender] & """")) Then
      Exit Sub
      Else
      d = DMax("[Datum_request]", "tblRequest ", "[Sender] = """ &
      Forms![fTest]![Sender] & """")
      endif
      There is always, when you have to use an expession of som
      heavyness( code lines or execution speed) twice or more, the
      possibility of using a temporary variable.
      temp = dmax(......)
      if not isnull(temp) then ....

      ... another thing is the nz statement
      d=nz(expression ,d)

      --
      Benny Andersen

      Comment

      • Albert D. Kallal

        #4
        Re: Double code

        Try:

        dim d as Variant

        d = DMax("[Datum_request]", "tblRequest ", _
        "[Sender] = """ & Forms![fTest]![Sender] & """")

        if isnull(d) then
        Exit Sub
        end if

        And, if the above is being run in form fTest, then:

        d = DMax("[Datum_request]", "tblRequest ", _
        "[Sender] = """ & me![Sender] & """")


        --
        Albert D. Kallal (Access MVP)
        Edmonton, Alberta Canada
        pleaseNOOSpamKa llal@msn.com



        Comment

        • Lars

          #5
          Re: Double code

          Thanks for the me! reminder!
          "Albert D. Kallal" <PleaseNOOOsPAM mkallal@msn.com schreef in bericht
          news:uW5Dj.9027 6$pM4.52763@pd7 urf1no...
          Try:
          >
          dim d as Variant
          >
          d = DMax("[Datum_request]", "tblRequest ", _
          "[Sender] = """ & Forms![fTest]![Sender] & """")
          >
          if isnull(d) then
          Exit Sub
          end if
          >
          And, if the above is being run in form fTest, then:
          >
          d = DMax("[Datum_request]", "tblRequest ", _
          "[Sender] = """ & me![Sender] & """")
          >
          >
          --
          Albert D. Kallal (Access MVP)
          Edmonton, Alberta Canada
          pleaseNOOSpamKa llal@msn.com
          >
          >
          >

          Comment

          Working...