javascript in a query's text string

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

    #1

    javascript in a query's text string

    Here is the scenario:

    1. I have a table (tblCalendar) with the following fields:
    caldID
    caldDate
    caldTitle
    caldInfo
    nWinW
    nWinH

    2. By design, when [caldInfo].value Is Null, [nWinW] and [nWinH] are both
    Not Null

    3. In order to filter and sort the data (because I want it for an .asp page)
    there is a query displaying the first four fields.

    4. Problem No1: I want to add a fifth field (column) in the query, that will
    display a text string ONLY WHEN the corresponding [caldInfo].value Is Null.

    5. Problem No2: That text string is the following javascript command:
    <a href="javascrip t:;" onClick="MM_ope nBrWindow('file Path','winName' ,
    'status=1,winWi dth,winHeight') ">Details.. .</a>

    6. Furthermore, the arguments of MM_openBrWindow () should be replaced by the
    following text/fieldnames:

    filePath = ../calendar/[caldID].htm
    winName = htm[caldID]
    status=1 = status=1 (the same)
    winWidth = [nWinW]
    winHeight = [nWinH]

    The general idea is that I don't know how to replace/escape the
    single/double quotes of the javascript, that should be inside the double
    quotes of the text string in the query.

    Can you help me please?

    ------- ---- --- -- - -
    [gt] aka geotso
    ------- ---- --- -- - -
    Please, remove hyphens to contact me

  • Larry Linson

    #2
    Re: javascript in a query's text string

    For Access/Jet SQL: If you are enclosing the string in double-quotes, double
    each internal double-quote, and don't change the single quotes, e.g., "The
    man said, ""Hello. Would you like a 'near-beer'?"""

    Larry Linson
    Microsoft Access MVP

    "geotso" <kata-ye-xi@yahoo.grwrot e in message
    news:e8j9aj$1fj 6$1@ulysses.noc .ntua.gr...
    Here is the scenario:
    >
    1. I have a table (tblCalendar) with the following fields:
    caldID
    caldDate
    caldTitle
    caldInfo
    nWinW
    nWinH
    >
    2. By design, when [caldInfo].value Is Null, [nWinW] and [nWinH] are both
    Not Null
    >
    3. In order to filter and sort the data (because I want it for an .asp
    page) there is a query displaying the first four fields.
    >
    4. Problem No1: I want to add a fifth field (column) in the query, that
    will display a text string ONLY WHEN the corresponding [caldInfo].value Is
    Null.
    >
    5. Problem No2: That text string is the following javascript command:
    <a href="javascrip t:;" onClick="MM_ope nBrWindow('file Path','winName' ,
    'status=1,winWi dth,winHeight') ">Details.. .</a>
    >
    6. Furthermore, the arguments of MM_openBrWindow () should be replaced by
    the following text/fieldnames:
    >
    filePath = ../calendar/[caldID].htm
    winName = htm[caldID]
    status=1 = status=1 (the same)
    winWidth = [nWinW]
    winHeight = [nWinH]
    >
    The general idea is that I don't know how to replace/escape the
    single/double quotes of the javascript, that should be inside the double
    quotes of the text string in the query.
    >
    Can you help me please?
    >
    ------- ---- --- -- - -
    [gt] aka geotso
    ------- ---- --- -- - -
    Please, remove hyphens to contact me

    Comment

    • geotso

      #3
      Re: javascript in a query's text string

      Larry,

      Thank you very much for your answer, that was the solution to my basic
      problem.

      Now, can you (or someone else) please explain to me how to limit the
      contents of the column shown the text string so, only the cells where the
      record's[caldInfo].Value Is Null (Problem No1 in my first post)?

      Please note that I've already found a (temporary) solution, using VBScript
      in my .asp page, but I would like to know if there is a solution into the
      database area.

      Thank you again...

      then, "Larry Linson" mounted the rostrum and spoke like this:
      For Access/Jet SQL: If you are enclosing the string in double-quotes,
      double each internal double-quote, and don't change the single quotes,
      e.g., "The man said, ""Hello. Would you like a 'near-beer'?"""
      >
      Larry Linson
      Microsoft Access MVP
      >
      "geotso" <kata-ye-xi@yahoo.grwrot e in message
      news:e8j9aj$1fj 6$1@ulysses.noc .ntua.gr...
      >Here is the scenario:
      >>
      >1. I have a table (tblCalendar) with the following fields:
      >caldID
      >caldDate
      >caldTitle
      >caldInfo
      >nWinW
      >nWinH
      >>
      >2. By design, when [caldInfo].value Is Null, [nWinW] and [nWinH] are both
      >Not Null
      >>
      >3. In order to filter and sort the data (because I want it for an .asp
      >page) there is a query displaying the first four fields.
      >>
      >4. Problem No1: I want to add a fifth field (column) in the query, that
      >will display a text string ONLY WHEN the corresponding [caldInfo].value
      >Is Null.
      >>
      >5. Problem No2: That text string is the following javascript command:
      ><a href="javascrip t:;" onClick="MM_ope nBrWindow('file Path','winName' ,
      >'status=1,winW idth,winHeight' )">Details.. .</a>
      >>
      >6. Furthermore, the arguments of MM_openBrWindow () should be replaced by
      >the following text/fieldnames:
      >>
      >filePath = ../calendar/[caldID].htm
      >winName = htm[caldID]
      >status=1 = status=1 (the same)
      >winWidth = [nWinW]
      >winHeight = [nWinH]
      >>
      >The general idea is that I don't know how to replace/escape the
      >single/double quotes of the javascript, that should be inside the double
      >quotes of the text string in the query.
      >>
      >Can you help me please?
      >>
      >------- ---- --- -- - -
      >[gt] aka geotso
      >------- ---- --- -- - -
      >Please, remove hyphens to contact me

      Comment

      • Larry Linson

        #4
        Re: javascript in a query's text string

        "geotso" <kata-ye-xi@yahoo.grwrot e
        Thank you very much for your answer, that
        was the solution to my basic problem.
        You are welcome. I'm glad I was able to assist.
        Now, can you (or someone else) please explain to me how to limit the
        contents of the column shown the text string so, only the cells where the
        record's[caldInfo].Value Is Null (Problem No1 in my first post)?
        In the Query Builder, the CalculatedField would be:

        FieldNameYouLik e: (IIF IsNull([caldInfo]), "your text string", "")

        Best of luck with your application.

        Larry Linson
        Microsoft Access MVP


        Please note that I've already found a (temporary) solution, using VBScript
        in my .asp page, but I would like to know if there is a solution into the
        database area.
        >
        Thank you again...
        >
        then, "Larry Linson" mounted the rostrum and spoke like this:
        >
        >For Access/Jet SQL: If you are enclosing the string in double-quotes,
        >double each internal double-quote, and don't change the single quotes,
        >e.g., "The man said, ""Hello. Would you like a 'near-beer'?"""
        >>
        >Larry Linson
        >Microsoft Access MVP
        >>
        >"geotso" <kata-ye-xi@yahoo.grwrot e in message
        >news:e8j9aj$1f j6$1@ulysses.no c.ntua.gr...
        >>Here is the scenario:
        >>>
        >>1. I have a table (tblCalendar) with the following fields:
        >>caldID
        >>caldDate
        >>caldTitle
        >>caldInfo
        >>nWinW
        >>nWinH
        >>>
        >>2. By design, when [caldInfo].value Is Null, [nWinW] and [nWinH] are
        >>both
        >>Not Null
        >>>
        >>3. In order to filter and sort the data (because I want it for an .asp
        >>page) there is a query displaying the first four fields.
        >>>
        >>4. Problem No1: I want to add a fifth field (column) in the query, that
        >>will display a text string ONLY WHEN the corresponding [caldInfo].value
        >>Is Null.
        >>>
        >>5. Problem No2: That text string is the following javascript command:
        >><a href="javascrip t:;" onClick="MM_ope nBrWindow('file Path','winName' ,
        >>'status=1,win Width,winHeight ')">Details.. .</a>
        >>>
        >>6. Furthermore, the arguments of MM_openBrWindow () should be replaced by
        >>the following text/fieldnames:
        >>>
        >>filePath = ../calendar/[caldID].htm
        >>winName = htm[caldID]
        >>status=1 = status=1 (the same)
        >>winWidth = [nWinW]
        >>winHeight = [nWinH]
        >>>
        >>The general idea is that I don't know how to replace/escape the
        >>single/double quotes of the javascript, that should be inside the double
        >>quotes of the text string in the query.
        >>>
        >>Can you help me please?
        >>>
        >>------- ---- --- -- - -
        >>[gt] aka geotso
        >>------- ---- --- -- - -
        >>Please, remove hyphens to contact me
        >

        Comment

        • geotso

          #5
          Re: javascript in a query's text string

          I'm afraid that something is wrong, because I get an error when I try to use
          the IIf function. According your suggestion the text string became:

          strText: (IIf IsNull([caldInfo]), "<a href=""javascri pt:;""
          onClick=""MM_op enBrWindow('../calendar/" & [caldID] & ".htm','" &
          [newWinName] & "','status=1,sc rollbars=1," & [newWinW] & "," & [newWinH] &
          "')"">Details.. .</a>", "")

          The error message is: "You must enclose IIf function arguments in
          parentheses" and when I close the message, the cursor has been inserted
          after the IsNull opening parenthesis.

          Do you see something wrong that I don't?

          Yet, thanks again for your help

          then, "Larry Linson" mounted the rostrum and spoke like this:
          "geotso" <kata-ye-xi@yahoo.grwrot e
          >
          >Thank you very much for your answer, that
          >was the solution to my basic problem.
          >
          You are welcome. I'm glad I was able to assist.
          >
          >Now, can you (or someone else) please explain to me how to limit the
          >contents of the column shown the text string so, only the cells where the
          >record's[caldInfo].Value Is Null (Problem No1 in my first post)?
          >
          In the Query Builder, the CalculatedField would be:
          >
          FieldNameYouLik e: (IIF IsNull([caldInfo]), "your text string", "")
          >
          Best of luck with your application.
          >
          Larry Linson
          Microsoft Access MVP
          >
          >
          >
          >Please note that I've already found a (temporary) solution, using
          >VBScript in my .asp page, but I would like to know if there is a
          >solution into the database area.
          >>
          >Thank you again...
          >>
          >then, "Larry Linson" mounted the rostrum and spoke like this:
          >>
          >>For Access/Jet SQL: If you are enclosing the string in double-quotes,
          >>double each internal double-quote, and don't change the single quotes,
          >>e.g., "The man said, ""Hello. Would you like a 'near-beer'?"""
          >>>
          >>Larry Linson
          >>Microsoft Access MVP
          >>>
          >>"geotso" <kata-ye-xi@yahoo.grwrot e in message
          >>news:e8j9aj$1 fj6$1@ulysses.n oc.ntua.gr...
          >>>Here is the scenario:
          >>>>
          >>>1. I have a table (tblCalendar) with the following fields:
          >>>caldID
          >>>caldDate
          >>>caldTitle
          >>>caldInfo
          >>>nWinW
          >>>nWinH
          >>>>
          >>>2. By design, when [caldInfo].value Is Null, [nWinW] and [nWinH] are
          >>>both
          >>>Not Null
          >>>>
          >>>3. In order to filter and sort the data (because I want it for an .asp
          >>>page) there is a query displaying the first four fields.
          >>>>
          >>>4. Problem No1: I want to add a fifth field (column) in the query, that
          >>>will display a text string ONLY WHEN the corresponding [caldInfo].value
          >>>Is Null.
          >>>>
          >>>5. Problem No2: That text string is the following javascript command:
          >>><a href="javascrip t:;" onClick="MM_ope nBrWindow('file Path','winName' ,
          >>>'status=1,wi nWidth,winHeigh t')">Details... </a>
          >>>>
          >>>6. Furthermore, the arguments of MM_openBrWindow () should be replaced
          >>>by the following text/fieldnames:
          >>>>
          >>>filePath = ../calendar/[caldID].htm
          >>>winName = htm[caldID]
          >>>status=1 = status=1 (the same)
          >>>winWidth = [nWinW]
          >>>winHeight = [nWinH]
          >>>>
          >>>The general idea is that I don't know how to replace/escape the
          >>>single/double quotes of the javascript, that should be inside the
          >>>double quotes of the text string in the query.
          >>>>
          >>>Can you help me please?
          >>>>
          >>>------- ---- --- -- - -
          >>>[gt] aka geotso
          >>>------- ---- --- -- - -
          >>>Please, remove hyphens to contact me

          Comment

          • Larry Linson

            #6
            Re: javascript in a query's text string


            "geotso" <kata-ye-xi@yahoo.grwrot e in message
            news:e8pi35$2hu o$1@ulysses.noc .ntua.gr...
            I'm afraid that something is wrong, because I get an error when I try to
            use the IIf function. According your suggestion the text string became:
            >
            strText: (IIf IsNull([caldInfo]), "<a href=""javascri pt:;""
            onClick=""MM_op enBrWindow('../calendar/" & [caldID] & ".htm','" &
            [newWinName] & "','status=1,sc rollbars=1," & [newWinW] & "," & [newWinH] &
            "')"">Details.. .</a>", "")
            >
            The error message is: "You must enclose IIf function arguments in
            parentheses" and when I close the message, the cursor has been inserted
            after the IsNull opening parenthesis.
            >
            Do you see something wrong that I don't?
            IIFs with long, complex text strings can be hard to diagnose. Consider
            putting that into a function in a standard module, which you can test using
            the immediate window, so that you aren't trying to debug a complex
            expression by running the query that contains it.

            Then you'd use it with something similar to:

            strText = MyNewFunction([caldInfo])

            Larry Linson
            Microsoft Access MVP

            Larry




            Comment

            Working...