Welcome to SPN

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

Sign Up Now!

textbox, strange behaviour.....

Discussion in 'Information Technology' started by Elaine, Jul 28, 2006.

  1. Elaine

    Elaine
    Expand Collapse
    Guest

    I created a form with a textbox, named txtSemester, whose Default Value is
    set to a function: =setSemester()*
    However, when I open the form, sometimes I get a #Error, other times I get
    the result I want......

    When I do get the #Error for the first time, I will keep on getting it,
    until I add a new textbox2 with the exactly same function as Default value.
    As soon as I add textbox2, txtSemester will start giving me the result I
    want.... it is really driving me mad!

    I know there's nothing wrong with the function because it does work.

    The only thing that is different with txtSemester is that I use it as an
    argument for the DLookup** function in a 3rd textbox. But I dont think this
    would be the cause of the error Im getting? or is it?

    Does anybody know of a reason for this odd behaviour? is it a bug?

    Please let me know if you need more details.
    Many thanks in advance

    Elaine

    *Public Function setSemester() As String
    Dim varCriteria As String
    On Error GoTo errSemester
    varCriteria = ""
    varCriteria = "[semStart] <= " & Format(Date, "\#mm\/dd\/yyyy\#") & " AND
    [semEnd] >= " & Format(Date, "\#mm\/dd\/yyyy\#")
    setSemester = DLookup("[Semester]", "tblSemester", varCriteria)
    errSemester:
    If Err.Number <> 0 Then
    MsgBox ("Error: " & Err.Number & " " & Err.Description)
    End If
    End Function

    **=DLookUp("[Invoiced Date]","tblInvoices","[Semester] =""" &
    Me!txtSemester)
     
  2. Loading...

    Similar Threads Forum Date
    SciTech Strange Blue World: Alien Planet's True Color Revealed, a First Breaking News Jul 12, 2013
    Truth Stranger Than Fiction! Interfaith Dialogues May 26, 2012
    Dr. Strangestlove (Or How I learned To Stop Worrying And Love My Computer) Inspirational Stories May 22, 2011
    Estranged Women Seek Help from Ramoowalia! Hard Talk Mar 9, 2011
    Nature Stranger Than Paradise (The Adivassi and FRA) Breaking News Jun 16, 2010

  3. Arvin Meyer [MVP]

    Arvin Meyer [MVP]
    Expand Collapse
    Guest

    Try checking your references:

    http://www.accessmvp.com/DJSteele/AccessReferenceErrors.html
    --
    Arvin Meyer, MCP, MVP
    Microsoft Access
    Free Access downloads
    http://www.datastrat.com
    http://www.mvps.org/access

    "Elaine" <elaine_ellul@yahoo.co.uk> wrote in message
    news:ur9xL7HiGHA.1272@TK2MSFTNGP03.phx.gbl...
    > I created a form with a textbox, named txtSemester, whose Default Value is
    > set to a function: =setSemester()*
    > However, when I open the form, sometimes I get a #Error, other times I get
    > the result I want......
    >
    > When I do get the #Error for the first time, I will keep on getting it,
    > until I add a new textbox2 with the exactly same function as Default

    value.
    > As soon as I add textbox2, txtSemester will start giving me the result I
    > want.... it is really driving me mad!
    >
    > I know there's nothing wrong with the function because it does work.
    >
    > The only thing that is different with txtSemester is that I use it as an
    > argument for the DLookup** function in a 3rd textbox. But I dont think

    this
    > would be the cause of the error Im getting? or is it?
    >
    > Does anybody know of a reason for this odd behaviour? is it a bug?
    >
    > Please let me know if you need more details.
    > Many thanks in advance
    >
    > Elaine
    >
    > *Public Function setSemester() As String
    > Dim varCriteria As String
    > On Error GoTo errSemester
    > varCriteria = ""
    > varCriteria = "[semStart] <= " & Format(Date, "\#mm\/dd\/yyyy\#") & " AND
    > [semEnd] >= " & Format(Date, "\#mm\/dd\/yyyy\#")
    > setSemester = DLookup("[Semester]", "tblSemester", varCriteria)
    > errSemester:
    > If Err.Number <> 0 Then
    > MsgBox ("Error: " & Err.Number & " " & Err.Description)
    > End If
    > End Function
    >
    > **=DLookUp("[Invoiced Date]","tblInvoices","[Semester] =""" &
    > Me!txtSemester)
    >
    >
     
  4. Elaine

    Elaine
    Expand Collapse
    Guest

    Hi Arvin, Many thanks but I'm afraid there wasnt a problem with my
    References. I imagine it is a bug.
    I worked around it by using a global variable to assign the Semester value
    to the textbox..

    Regards,

    Elaine
    "Arvin Meyer [MVP]" <a@m.com> wrote in message
    news:eHd7xMJiGHA.1612@TK2MSFTNGP04.phx.gbl...
    > Try checking your references:
    >
    > http://www.accessmvp.com/DJSteele/AccessReferenceErrors.html
    > --
    > Arvin Meyer, MCP, MVP
    > Microsoft Access
    > Free Access downloads
    > http://www.datastrat.com
    > http://www.mvps.org/access
    >
    > "Elaine" <elaine_ellul@yahoo.co.uk> wrote in message
    > news:ur9xL7HiGHA.1272@TK2MSFTNGP03.phx.gbl...
    >> I created a form with a textbox, named txtSemester, whose Default Value
    >> is
    >> set to a function: =setSemester()*
    >> However, when I open the form, sometimes I get a #Error, other times I
    >> get
    >> the result I want......
    >>
    >> When I do get the #Error for the first time, I will keep on getting it,
    >> until I add a new textbox2 with the exactly same function as Default

    > value.
    >> As soon as I add textbox2, txtSemester will start giving me the result I
    >> want.... it is really driving me mad!
    >>
    >> I know there's nothing wrong with the function because it does work.
    >>
    >> The only thing that is different with txtSemester is that I use it as an
    >> argument for the DLookup** function in a 3rd textbox. But I dont think

    > this
    >> would be the cause of the error Im getting? or is it?
    >>
    >> Does anybody know of a reason for this odd behaviour? is it a bug?
    >>
    >> Please let me know if you need more details.
    >> Many thanks in advance
    >>
    >> Elaine
    >>
    >> *Public Function setSemester() As String
    >> Dim varCriteria As String
    >> On Error GoTo errSemester
    >> varCriteria = ""
    >> varCriteria = "[semStart] <= " & Format(Date, "\#mm\/dd\/yyyy\#") & " AND
    >> [semEnd] >= " & Format(Date, "\#mm\/dd\/yyyy\#")
    >> setSemester = DLookup("[Semester]", "tblSemester", varCriteria)
    >> errSemester:
    >> If Err.Number <> 0 Then
    >> MsgBox ("Error: " & Err.Number & " " & Err.Description)
    >> End If
    >> End Function
    >>
    >> **=DLookUp("[Invoiced Date]","tblInvoices","[Semester] =""" &
    >> Me!txtSemester)
    >>
    >>

    >
    >
     

Share This Page