Microsoft KB Archive/253976: Difference between revisions

From BetaArchive Wiki
m (Text replacement - "<" to "<")
m (Text replacement - """ to """)
 
(2 intermediate revisions by the same user not shown)
Line 81: Line 81:


<ol>
<ol>
<li>Create a data access page that is based on the &quot;Employees Sales by Country&quot; query in the Northwind sample database. Save it as <span class="kbd userinput"> EmpSalesByCountry.htm</span>.</li>
<li>Create a data access page that is based on the "Employees Sales by Country" query in the Northwind sample database. Save it as <span class="kbd userinput"> EmpSalesByCountry.htm</span>.</li>
<li>In Design view for the page, click '''Macro''' on the '''Tools''' menu, and then click '''Microsoft Script Editor'''.</li>
<li>In Design view for the page, click '''Macro''' on the '''Tools''' menu, and then click '''Microsoft Script Editor'''.</li>
<li><p>Add the following script immediately before the closing HEAD tag for the page:</p>
<li><p>Add the following script immediately before the closing HEAD tag for the page:</p>
<pre class="codesample"><SCRIPT language=vbscript&gt;
<pre class="codesample"><SCRIPT language=vbscript>
<!--
<!--
Document.MSODSC.RecordsetDefs(0).ParameterValues.Add &quot;[Beginning Date]&quot;, _
Document.MSODSC.RecordsetDefs(0).ParameterValues.Add "[Beginning Date]", _
inputbox(&quot;Enter Beginning Date&quot;,&quot;[Beginning Date]&quot;,#1/1/1996#)
inputbox("Enter Beginning Date","[Beginning Date]",#1/1/1996#)


Document.MSODSC.RecordsetDefs(0).ParameterValues.Add &quot;[Ending Date]&quot;, _
Document.MSODSC.RecordsetDefs(0).ParameterValues.Add "[Ending Date]", _
inputbox(&quot;Enter Ending date&quot;,&quot;[Ending Date]&quot;,#1/1/1997#)
inputbox("Enter Ending date","[Ending Date]",#1/1/1997#)
--&gt;
-->
</SCRIPT&gt;
</SCRIPT>
                     </pre>
                     </pre>
<p>'''NOTE''': For pages that are based on SQL Server stored procedures, use the following syntax:</p>
<p>'''NOTE''': For pages that are based on SQL Server stored procedures, use the following syntax:</p>
<pre class="codesample"><SCRIPT language=vbscript&gt;
<pre class="codesample"><SCRIPT language=vbscript>
<!--
<!--
Document.MSODSC.RecordsetDefs(0).ParameterValues.Add &quot;@Beginning_Date&quot;, _  
Document.MSODSC.RecordsetDefs(0).ParameterValues.Add "@Beginning_Date", _  
inputbox(&quot;Enter Beginning Date&quot;,&quot;Beginning Date&quot;,#1/1/1996#)
inputbox("Enter Beginning Date","Beginning Date",#1/1/1996#)
   
   
Document.MSODSC.RecordsetDefs(0).ParameterValues.Add &quot;@Ending_Date&quot;, _  
Document.MSODSC.RecordsetDefs(0).ParameterValues.Add "@Ending_Date", _  
inputbox(&quot;Enter Ending Date&quot;,&quot;Ending Date&quot;,#1/1/1997#)
inputbox("Enter Ending Date","Ending Date",#1/1/1997#)
--&gt;
-->
</SCRIPT&gt;
</SCRIPT>
                     </pre></li></ol>
                     </pre></li></ol>


Line 110: Line 110:
<ol>
<ol>
<li><p>Create a file that contains the following HTML, and then save it as <span class="kbd userinput"> dapOpen.htm</span>:</p>
<li><p>Create a file that contains the following HTML, and then save it as <span class="kbd userinput"> dapOpen.htm</span>:</p>
<pre class="codesample"><HTML&gt;
<pre class="codesample"><HTML>
   <HEAD&gt;
   <HEAD>
   <TITLE&gt;Enter Date Range</TITLE&gt;
   <TITLE>Enter Date Range</TITLE>
   <SCRIPT language=&quot;VBScript&quot;&gt;
   <SCRIPT language="VBScript">
   Sub writeCookie(strVariableName, varVariableValue)
   Sub writeCookie(strVariableName, varVariableValue)
       Document.Cookie = strVariableName &amp; &quot;=&quot; &amp; varVariableValue
       Document.Cookie = strVariableName & "=" & varVariableValue
   End Sub
   End Sub


Line 125: Line 125:
       varEnd = document.all.txtEnd.value
       varEnd = document.all.txtEnd.value


       writeCookie &quot;pBegin&quot;, varBegin
       writeCookie "pBegin", varBegin
       writeCookie &quot;pEnd&quot;, varEnd
       writeCookie "pEnd", varEnd
       'change &quot;servername&quot; to the name of your server.
       'change "servername" to the name of your server.
       window.navigate(&quot;http://servername/EmpSalesByCountry.htm&quot;)
       window.navigate("http://servername/EmpSalesByCountry.htm")


   End Sub
   End Sub
   </SCRIPT&gt;
   </SCRIPT>
   </HEAD&gt;
   </HEAD>
   <BODY&gt;
   <BODY>
   <FORM id=&quot;form1&quot;&gt;
   <FORM id="form1">
     <TABLE&gt;
     <TABLE>
       <TR&gt;
       <TR>
         <TD&gt;Beginning Date:</TD&gt;
         <TD>Beginning Date:</TD>
         <TD&gt;<input type=&quot;text&quot; name=&quot;txtBegin&quot; size=&quot;20&quot;&gt;</TD&gt;
         <TD><input type="text" name="txtBegin" size="20"></TD>
       </TR&gt;
       </TR>
       <TR&gt;
       <TR>
     <TD&gt;Ending Date:</TD&gt;
     <TD>Ending Date:</TD>
         <TD&gt;<input type=&quot;text&quot; name=&quot;txtEnd&quot; size=&quot;20&quot;&gt;</TD&gt;
         <TD><input type="text" name="txtEnd" size="20"></TD>
       </TR&gt;
       </TR>
     </TABLE&gt;
     </TABLE>
     <P&gt;<input type=&quot;button&quot; value=&quot;Open DAP&quot;
     <P><input type="button" value="Open DAP"
         name=&quot;B2&quot; onClick=&quot;openDAP()&quot;&gt;</P&gt;
         name="B2" onClick="openDAP()"></P>
   </FORM&gt;
   </FORM>
   </BODY&gt;
   </BODY>
</HTML&gt;
</HTML>
                     </pre></li>
                     </pre></li>
<li>Create a data access page that is based on the &quot;Employees Sales by Country&quot; query in the Northwind sample database. Save it as <span class="kbd userinput"> EmpSalesByCountry.htm</span>.</li>
<li>Create a data access page that is based on the "Employees Sales by Country" query in the Northwind sample database. Save it as <span class="kbd userinput"> EmpSalesByCountry.htm</span>.</li>
<li><p>In Design view for the page, click '''Macro''' on the '''Tools''' menu, and then click '''Microsoft Script Editor'''. Add the following script immediately before the closing HEAD tag for the page:</p>
<li><p>In Design view for the page, click '''Macro''' on the '''Tools''' menu, and then click '''Microsoft Script Editor'''. Add the following script immediately before the closing HEAD tag for the page:</p>
<pre class="codesample"><SCRIPT language=&quot;VBScript&quot;&gt;
<pre class="codesample"><SCRIPT language="VBScript">
Function readCookie(strVariableName)
Function readCookie(strVariableName)
   Dim intLocation
   Dim intLocation
Line 168: Line 168:


   ' Find the position of the next semicolon.
   ' Find the position of the next semicolon.
   intNextSemicolon = Instr(strTemp, &quot;;&quot;)
   intNextSemicolon = Instr(strTemp, ";")


   ' If not found, assume you are at the end.
   ' If not found, assume you are at the end.
Line 178: Line 178:
   readCookie = Mid(strTemp, intNameLength + 2, intValueLength)
   readCookie = Mid(strTemp, intNameLength + 2, intValueLength)
End Function
End Function
</SCRIPT&gt;
</SCRIPT>
                     </pre>
                     </pre>
<pre class="codesample"><SCRIPT language=&quot;VBScript&quot;&gt;
<pre class="codesample"><SCRIPT language="VBScript">
   Dim startDate
   Dim startDate
   Dim endDate
   Dim endDate
   startDate = &quot;pBegin&quot;
   startDate = "pBegin"
   startDate = readCookie(startDate)
   startDate = readCookie(startDate)
   endDate = &quot;pEnd&quot;
   endDate = "pEnd"
   endDate = readCookie(endDate)
   endDate = readCookie(endDate)
   Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
   Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
       &quot;[Beginning Date]&quot;, startDate
       "[Beginning Date]", startDate
   Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
   Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
       &quot;[Ending Date]&quot;, endDate
       "[Ending Date]", endDate


'For pages based on SQL Server stored procedures, use the following syntax:
'For pages based on SQL Server stored procedures, use the following syntax:
'  Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
'  Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
'      &quot;@Beginning_Date&quot;, startDate
'      "@Beginning_Date", startDate
'  Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
'  Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
'      &quot;@Ending_Date&quot;, endDate
'      "@Ending_Date", endDate
</SCRIPT&gt;
</SCRIPT>
                     </pre></li>
                     </pre></li>
<li>Open the page by using the '''http://servername/dapOpen.htm''' URL, the HTML file that you created in step 1, instead of opening EmpSalesByCountry.htm directly.</li></ol>
<li>Open the page by using the '''http://servername/dapOpen.htm''' URL, the HTML file that you created in step 1, instead of opening EmpSalesByCountry.htm directly.</li></ol>

Latest revision as of 12:53, 21 July 2020

Article ID: 253976

Article Last Modified on 8/17/2007



APPLIES TO

  • Microsoft Access 2000 Standard Edition



This article was previously published under Q253976

Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).


SYMPTOMS

When you try to print a data access page that is based on a parameter query in Microsoft Internet Explorer 5.0, the page is not printed.

CAUSE

When you print from Internet Explorer, a new document object is created for the print job. When the Microsoft Office Web Components are reloaded during the print job, they detect that parameter values are required and attempt to display a dialog box to get the values. In versions of Internet Explorer earlier than 5.5, Internet Explorer cannot provide the correct window context to display the dialog box at this point. Therefore, the page is not printed and you do not receive an error message. Additional attempts to print the page do not work until you quit Internet Explorer, and then restart it.

RESOLUTION

To resolve this problem, upgrade to Microsoft Internet Explorer 5.5 or later. To obtain the latest version of Internet Explorer, visit the following Microsoft Web site:

To work around this problem without upgrading, you can use one of the following methods:

  • Method 1: Use Script from the Page to Prompt for the Parameter Values
  • Method 2: Use Script to Create and Read Cookies That Are Based on Values That Are Entered on a Separate Page

Method 1: Use Script from the Page to Prompt for the Parameter Values

  1. Create a data access page that is based on the "Employees Sales by Country" query in the Northwind sample database. Save it as EmpSalesByCountry.htm.
  2. In Design view for the page, click Macro on the Tools menu, and then click Microsoft Script Editor.
  3. Add the following script immediately before the closing HEAD tag for the page:

    <SCRIPT language=vbscript>
    <!--
    Document.MSODSC.RecordsetDefs(0).ParameterValues.Add "[Beginning Date]", _
    inputbox("Enter Beginning Date","[Beginning Date]",#1/1/1996#)
    
    Document.MSODSC.RecordsetDefs(0).ParameterValues.Add "[Ending Date]", _
    inputbox("Enter Ending date","[Ending Date]",#1/1/1997#)
    -->
    </SCRIPT>
                        

    NOTE: For pages that are based on SQL Server stored procedures, use the following syntax:

    <SCRIPT language=vbscript>
    <!--
    Document.MSODSC.RecordsetDefs(0).ParameterValues.Add "@Beginning_Date", _ 
    inputbox("Enter Beginning Date","Beginning Date",#1/1/1996#)
     
    Document.MSODSC.RecordsetDefs(0).ParameterValues.Add "@Ending_Date", _ 
    inputbox("Enter Ending Date","Ending Date",#1/1/1997#)
    -->
    </SCRIPT>
                        

Method 2: Use Script to Create and Read Cookies That Are Based on Values That Are Entered on a Separate Page

  1. Create a file that contains the following HTML, and then save it as dapOpen.htm:

    <HTML>
      <HEAD>
      <TITLE>Enter Date Range</TITLE>
      <SCRIPT language="VBScript">
       Sub writeCookie(strVariableName, varVariableValue)
          Document.Cookie = strVariableName & "=" & varVariableValue
       End Sub
    
       Sub openDAP()
          Dim varBegin 
          Dim varEnd 
                  
          varBegin = document.all.txtBegin.value
          varEnd = document.all.txtEnd.value
    
          writeCookie "pBegin", varBegin
          writeCookie "pEnd", varEnd
          'change "servername" to the name of your server.
          window.navigate("http://servername/EmpSalesByCountry.htm")
    
       End Sub
      </SCRIPT>
      </HEAD>
      <BODY>
       <FORM id="form1">
         <TABLE>
           <TR>
             <TD>Beginning Date:</TD>
             <TD><input type="text" name="txtBegin" size="20"></TD>
           </TR>
           <TR>
         <TD>Ending Date:</TD>
             <TD><input type="text" name="txtEnd" size="20"></TD>
           </TR>
        </TABLE>
        <P><input type="button" value="Open DAP"
            name="B2" onClick="openDAP()"></P>
      </FORM>
      </BODY>
    </HTML>
                        
  2. Create a data access page that is based on the "Employees Sales by Country" query in the Northwind sample database. Save it as EmpSalesByCountry.htm.
  3. In Design view for the page, click Macro on the Tools menu, and then click Microsoft Script Editor. Add the following script immediately before the closing HEAD tag for the page:

    <SCRIPT language="VBScript">
    Function readCookie(strVariableName)
       Dim intLocation
       Dim intNameLength
       Dim intValueLength
       Dim intNextSemicolon
       Dim strTemp
    
       ' Calculate length and location of variable name.
       intNameLength = Len(strVariableName)
       intLocation = Instr(Document.Cookie, strVariableName)
        
       strTemp = Right(Document.Cookie, Len(Document.Cookie) - intLocation + 1)
    
       ' Find the position of the next semicolon.
       intNextSemicolon = Instr(strTemp, ";")
    
       ' If not found, assume you are at the end.
       If intNextSemicolon = 0 Then 
          intNextSemicolon = Len(strTemp) + 1
       End If
        
       intValueLength = intNextSemicolon - intNameLength - 2
       readCookie = Mid(strTemp, intNameLength + 2, intValueLength)
    End Function
    </SCRIPT>
                        
    <SCRIPT language="VBScript">
       Dim startDate
       Dim endDate
       startDate = "pBegin"
       startDate = readCookie(startDate)
       endDate = "pEnd"
       endDate = readCookie(endDate)
       Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
          "[Beginning Date]", startDate
       Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
          "[Ending Date]", endDate
    
    'For pages based on SQL Server stored procedures, use the following syntax:
    '   Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
    '      "@Beginning_Date", startDate
    '   Document.MSODSC.Recordsetdefs(0).ParameterValues.Add _
    '      "@Ending_Date", endDate
    </SCRIPT>
                        
  4. Open the page by using the http://servername/dapOpen.htm URL, the HTML file that you created in step 1, instead of opening EmpSalesByCountry.htm directly.


STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Open the Northwind.mdb sample database.
  2. Create a new query.
  3. On the View menu, click SQL View.
  4. Type the following SQL statement:

    PARAMETERS a Text ( 255 );
    
    SELECT Customers.CustomerID, Customers.CompanyName
    FROM Customers
    WHERE (((Customers.CustomerID)=[a]));
                        
  5. Save and then close the query.
  6. Create a new data access page that is based on the query.
  7. Save the page to a Web folder, and then close it.
  8. Open the page in Internet Explorer 5.0.
  9. Type ALFKI when you are prompted for the parameter.
  10. On the File menu, click Print.

Notice that the page is never printed. Additional attempts to print the page do not work until you quit Internet Explorer, and then restart it.


Additional query words: pra

Keywords: kbbug kbfix KB253976