<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://vstoolsforum.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Microsoft Access</title><subtitle type="html">Tricks and Tips for Microsoft Access</subtitle><id>http://vstoolsforum.com/blogs/microsoft_access/atom.aspx</id><link rel="alternate" type="text/html" href="http://vstoolsforum.com/blogs/microsoft_access/default.aspx" /><link rel="self" type="application/atom+xml" href="http://vstoolsforum.com/blogs/microsoft_access/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20611.960">Community Server</generator><updated>2008-07-29T14:40:00Z</updated><entry><title>Code to loop through the querydefs collection in Access</title><link rel="alternate" type="text/html" href="http://vstoolsforum.com/blogs/microsoft_access/archive/2009/02/26/code-to-loop-through-the-querydefs-collection-in-access.aspx" /><id>http://vstoolsforum.com/blogs/microsoft_access/archive/2009/02/26/code-to-loop-through-the-querydefs-collection-in-access.aspx</id><published>2009-02-27T03:00:00Z</published><updated>2009-02-27T03:00:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;Recently I was migrating some tables to SQL from an old Access database. The original programmer had put spaces and other punctuation in the field names that SQL didn&amp;#39;t allow so I changed them, but that broke Access when I linked the table back. This code will loop through the querydef collection and find all instances of a table name or field name. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre style="overflow: scroll; background-color: #f2f2f2;"&gt;&lt;span style="color: Black;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Sub&lt;/span&gt; custom()
    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Dim&lt;/span&gt; strSQL &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;As&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;String&lt;/span&gt;
    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Dim&lt;/span&gt; qry &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;As&lt;/span&gt; QueryDef
    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Dim&lt;/span&gt; db &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;As&lt;/span&gt; Database
    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Set&lt;/span&gt; db &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;=&lt;/span&gt; CurrentDb
    
    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;For&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Each&lt;/span&gt; qry &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;In&lt;/span&gt; db.QueryDefs
        strSQL &lt;span style="color: Red;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;=&lt;/span&gt; qry.SQL
        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;If&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;InStr&lt;/span&gt;(strSQL, &lt;span style="color: #666666;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;"[Product Master].[Product Number]"&lt;/span&gt;) &amp;gt; 0 &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Then&lt;/span&gt;
            
            Debug.&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Print&lt;/span&gt; qry.Name
            
            
            &lt;span style="color: Green;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;'MsgBox qry.Name&lt;/span&gt;
            Debug.&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Print&lt;/span&gt; strSQL
            Debug.&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Print&lt;/span&gt; &lt;span style="color: #666666;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;"======================="&lt;/span&gt;
        &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;End&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;If&lt;/span&gt;
        
    &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Next&lt;/span&gt;


&lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;End&lt;/span&gt; &lt;span style="color: Blue;background-color: Transparent;font-family: Courier New;font-size: 11px;font-weight: normal;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/p&gt;&lt;img src="http://vstoolsforum.com/aggbug.aspx?PostID=1646" width="1" height="1"&gt;</content><author><name>Steve Gray</name><uri>http://vstoolsforum.com/members/Steve-Gray.aspx</uri></author></entry><entry><title>VBA ADODB Frequent Error with adDate or adDBdate parameter </title><link rel="alternate" type="text/html" href="http://vstoolsforum.com/blogs/microsoft_access/archive/2008/11/14/vba-adodb-frequent-error-with-addate-or-addbdate-parameter.aspx" /><id>http://vstoolsforum.com/blogs/microsoft_access/archive/2008/11/14/vba-adodb-frequent-error-with-addate-or-addbdate-parameter.aspx</id><published>2008-11-14T17:56:00Z</published><updated>2008-11-14T17:56:00Z</updated><content type="html">&lt;p&gt;using &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font face="Calibri" size="3"&gt;[code language=’vb’]&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;cmd.Parameters.Append cmd.CreateParameter(&amp;quot;@dtDate&amp;quot;, adDate, adParamInput, 0, &amp;quot;11/13/2008&amp;quot;) &lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;mso-margin-top-alt:auto;"&gt;&lt;font face="Calibri" size="3"&gt;[/code]&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;mso-margin-top-alt:auto;"&gt;&lt;font face="Calibri" size="3"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN:0in 0in 0pt;mso-margin-top-alt:auto;"&gt;it would return this error:&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;&amp;quot;Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.&amp;quot;&lt;/p&gt;
&lt;p&gt;Fix by using &lt;u&gt;adDBTimeStamp&lt;/u&gt;&lt;/p&gt;&lt;img src="http://vstoolsforum.com/aggbug.aspx?PostID=1381" width="1" height="1"&gt;</content><author><name>steve gray</name><uri>http://vstoolsforum.com/members/steve-gray.aspx</uri></author></entry><entry><title>Stock report opening code for Access</title><link rel="alternate" type="text/html" href="http://vstoolsforum.com/blogs/microsoft_access/archive/2008/07/29/stock-report-opening-code-for-access.aspx" /><id>http://vstoolsforum.com/blogs/microsoft_access/archive/2008/07/29/stock-report-opening-code-for-access.aspx</id><published>2008-07-29T18:40:00Z</published><updated>2008-07-29T18:40:00Z</updated><content type="html">&lt;p&gt;I put the following code in all my Access reports &lt;/p&gt;
&lt;p&gt;&lt;pre style="overflow: scroll; background-color: #f2f2f2;"&gt; Option Explicit
Dim strCompanyID As String
Dim strFormName As String
Dim mlngBgColor As Long
Dim mintCount As Integer


Private Sub Report_Close()
    If isOpen(strFormName) Then
        DoCmd.Close acForm, strFormName
        DoCmd.Restore
    End If
End Sub


Private Sub Report_Open(Cancel As Integer)
    
    Dim strDatabase As String
    Dim strStartProject As String
    Dim strEndProject As String
    Dim strStartDate As String
    Dim strEndDate As String
    
    strFormName = "frmCostCatSummary"
    
    DoCmd.OpenForm strFormName, acNormal, , , , acDialog
    
    If isOpen(strFormName) Then
        DoCmd.Maximize
        
        strStartProject = Trim(Forms!frmCostCatSummary!cboStartProject)
        strEndProject = Trim(Nz(Forms!frmCostCatSummary!cboEndProject))
        strStartDate = Trim(Nz(Forms!frmCostCatSummary!txtDate1))
        strEndDate = Trim(Nz(Forms!frmCostCatSummary!txtDate2))
        
        strCompanyID = setDatabase("qryCostCatSummary", "sp_EP_CostCatSummary '" &amp; strStartProject &amp; "','" &amp; strEndProject &amp; "','" &amp; strStartDate &amp; "','" &amp; strEndDate &amp; "'")
        lblCompanyID.Caption = strCompanyID
    Else
        Cancel = True
    End If
End Sub&lt;/pre&gt;&lt;/p&gt;&lt;img src="http://vstoolsforum.com/aggbug.aspx?PostID=1175" width="1" height="1"&gt;</content><author><name>Steve Gray</name><uri>http://vstoolsforum.com/members/Steve-Gray.aspx</uri></author></entry></feed>