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

    Subform Text Box Default Value (2003)

    If I select March 2008 on the startup form in the attached mdb, how can I get the S1Hi text box in the FrmCons subform to display the previous month's value as its default value? Setting the DefaultValue property =Dlookup("S1Hi", "Consumi", "mese=" & Forms!MInsConsumi!Cmese -1 & " and anno =" & Forms!MInsConsumi!Canno) works only if the previous month's year is the same as the current month's.
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subform Text Box Default Value (2003)

    Try

    =IIf(Forms!MInsConsumi!Cmese=1,Dlookup("S1Hi", "Consumi", "mese=12 and anno=" & Forms!MInsConsumi!Canno-1),Dlookup("S1Hi", "Consumi", "mese=" & Forms!MInsConsumi!Cmese-1 & " and anno=" & Forms!MInsConsumi!Canno))

    <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform Text Box Default Value (2003)

    Hi Hans, that's odd, I select March 2008 but the S1Hi text box displays #Error.
    Attached Files Attached Files

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subform Text Box Default Value (2003)

    Put a text box txtDefault on the main form with control source

    =IIf([Cmese]=1,DLookUp("S1Hi","Consumi","mese=12 and anno=" & [Canno]-1),DLookUp("S1Hi","Consumi","mese=" & [Cmese]-1 & " and anno=" & [Canno]))

    You can hide this text box by setting its Visible property to False.

    Set the Default Value property of S1H1 to

    =[Parent]![txtDefault]

    You'll still get #Error if Cmese or Canno is blank.

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform Text Box Default Value (2003)

    Thank you Hans,
    I've got around the "#Error if Cmese or Canno is blank" problem by setting the control source of the hidden text box to:
    =IIf(IsNull([Cmese]) Or IsNull([Canno]),"",IIf([Cmese]=1,DLookUp("S1Hf","Consumi","mese=12 and anno=" & [Canno]-1),DLookUp("S1Hf","Consumi","mese=" & [Cmese]-1 & " and anno=" & [Canno])))

Posting Permissions

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