Results 1 to 2 of 2
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Alzano Lombardo, Italy
    Thanked 0 Times in 0 Posts

    Dlookup Function Type Mismatch (2000)

    The ENERGIA text box in the subform of the attached mdb uses the Dlookup function to find the previous-day value for the LETTUR text box on the same subform so I thought of using the same function to set the default value for the LETTUR text box (see attachment) but as soon as I select a date, say January 4, 2004 on the calendar I get a type mismatch error. Here's the content of the default value box:

    =IIf(IsNull([giorno]),"",IIf(IsNull(DLookUp("Lettur","G1Dez","Giorno=# " & Format([Giorno]-1,"mm/dd/yyyy") & "#")),"",DLookUp("Lettur","G1Dez","Giorno=#" & Format([Giorno]-1,"mm/dd/yyyy") & "#")))

    How to fix it?
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Dlookup Function Type Mismatch (2000)

    I don't think you can set the default value this way. DefaultValue is read when a form is opened, and not updated in between, but you want a dynamic expression. Therefore you should set it in code, in the On Current event of the subform. See attached version.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts