<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: access code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 25 Jul 2008 01:28:52 GMT</pubDate>
    <description>DZone Snippets: access code</description>
    <item>
      <title>Restrict access to your website</title>
      <link>http://snippets.dzone.com/posts/show/5801</link>
      <description>This statement was added to my virtual host .conf file, to allow only Intranet traffic to  my website.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Allow from 192. 10.&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Mon, 21 Jul 2008 15:43:38 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5801</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Add lines of code to module in design view using VBEIDE</title>
      <link>http://snippets.dzone.com/posts/show/5436</link>
      <description>Sometimes you'll need to add code programmatically to your Form or Report Module, for example, when you need to add the same code to all controls of a certain type on a form. When the form has a handful of controls it's no big deal, but when there may be dozens or hundreds of controls it can be daunting. The code below will cycle through all of the controls on your form, determine if the control type has to be updated, check to see if the control already has an event defined, and if not, create the event and append the code. Otherwise it'll print the name of the procedure it didn't modify. Prior to running the code please add the reference "Microsoft Visual Basic for Applications Extensibility 5.3" to your project. &lt;br /&gt;&lt;br /&gt;Note: The form specified in strForm below must be in design view prior to running the code in order for this to work. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can call the procedure using:&lt;br /&gt;AddCodeToControls("Form_myForm", "Msgbox " &amp; chr(34) &amp; "Hello World" &amp; chr(34) , "BeforeUpdate"&lt;br /&gt;&lt;br /&gt;&lt;Code&gt;&lt;br /&gt;' This code was originally written by Juan Soto at AccessExperts.net.&lt;br /&gt;' It is not to be altered or distributed,&lt;br /&gt;' except as part of an application.&lt;br /&gt;' You are free to use it in any application,&lt;br /&gt;' provided the copyright notice is left unchanged.&lt;br /&gt;'&lt;br /&gt;' Code Courtesy of&lt;br /&gt;' Juan Soto at AccessExperts.net&lt;br /&gt;&lt;br /&gt;Public Function AddCodeToControls(strFormName As String, strCode As String, strProcedure As String)&lt;br /&gt;    On Error Resume Next&lt;br /&gt;    Dim VBAEditor As VBIDE.VBE&lt;br /&gt;    Dim VBProj As VBIDE.VBProject&lt;br /&gt;    Dim VBComp As VBIDE.VBComponent&lt;br /&gt;    Dim CodeMod As VBIDE.CodeModule&lt;br /&gt;    Dim obj As Object&lt;br /&gt;    Dim frm As Form&lt;br /&gt;    Dim ctl As Access.Control&lt;br /&gt;    Dim lngHeaderLine As Long&lt;br /&gt;    &lt;br /&gt;    Set VBAEditor = Application.VBE&lt;br /&gt;    Set VBProj = VBAEditor.ActiveVBProject&lt;br /&gt;    Set VBComp = VBProj.VBComponents(strFormName)&lt;br /&gt;    Set CodeMod = VBComp.CodeModule&lt;br /&gt;    Set frm = Forms(strform)&lt;br /&gt;    For Each ctl In frm.Controls&lt;br /&gt;        If ctl.ControlType = acCheckBox Or ctl.ControlType = acComboBox Or ctl.ControlType = acListBox _&lt;br /&gt;            Or ctl.ControlType = acTextBox Then&lt;br /&gt;            'Search if object already has an after update event&lt;br /&gt;            lngHeaderLine = CodeMod.ProcStartLine(ctl.Name &amp; "_" &amp; strProcedure, vbext_pk_Proc)&lt;br /&gt;            If Err &gt; 0 Then&lt;br /&gt;                'Procedure does not exist, create it&lt;br /&gt;                lngHeaderLine = CodeMod.CreateEventProc(strProcedure, ctl.Name)&lt;br /&gt;                CodeMod.InsertLines lngHeaderLine + 1, strCode&lt;br /&gt;            Else&lt;br /&gt;                'Procedure does exist, print name for manual editing later&lt;br /&gt;                Debug.Print ctl.Name &amp; "_" &amp; strProcedure &amp; " Not Modified"&lt;br /&gt;            End If&lt;br /&gt;        End If&lt;br /&gt;    Next ctl&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;/Code&gt;</description>
      <pubDate>Mon, 28 Apr 2008 01:38:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5436</guid>
      <author>AccessExpert (Juan Soto)</author>
    </item>
    <item>
      <title>PHP : Conectar con Access / Connect with Access</title>
      <link>http://snippets.dzone.com/posts/show/4345</link>
      <description>Conectar con Access / Connect with Access.&lt;br /&gt;C&#243;digo fuente / Source code :&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$pathDB = str_replace("/", "\\", $_SERVER["DOCUMENT_ROOT"]) . "\\directory1\\directory2\\bdd.mdb";&lt;br /&gt;&lt;br /&gt;if(!file_exists($pathDB))&lt;br /&gt;{&lt;br /&gt;echo "!!! Base de datos no encontrada ".$pathDB;&lt;br /&gt;exit;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$conexion = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".$pathDB, "ADODB.Connection", "", "SQL_CUR_USE_ODBC");&lt;br /&gt;$sql="select * from tabla where 1";&lt;br /&gt;$resultado=odbc_exec($conexion,$sql);&lt;br /&gt;if($resultado)&lt;br /&gt;{&lt;br /&gt;	while($fila=odbc_fetch_array($resultado))&lt;br /&gt;	{&lt;br /&gt;	echo $fila['campo1']."&lt;br /&gt;";&lt;br /&gt;	echo $fila['campo2']."&lt;br /&gt;";&lt;br /&gt;	}&lt;br /&gt;odbc_close_all();&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 23 Jul 2007 10:55:33 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4345</guid>
      <author>Ricardo (Ricardo m. Garc&#237;a)</author>
    </item>
    <item>
      <title>Close all forms in Access</title>
      <link>http://snippets.dzone.com/posts/show/3911</link>
      <description>Sometimes, it's necessary to close all forms in a single procedure:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Function CloseAllForms()&lt;br /&gt;&lt;br /&gt;'It will close all forms before opening the new form (if required)&lt;br /&gt;&lt;br /&gt;Dim obj As Object&lt;br /&gt;Dim strName As String&lt;br /&gt;&lt;br /&gt;For Each obj In Application.CurrentProject.AllForms&lt;br /&gt;DoCmd.Close acForm, obj.name, acSaveYes&lt;br /&gt;Next obj&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Close all forms - except one particular screen:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Function CloseAllForms()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Dim obj As Object&lt;br /&gt;Dim strName As String&lt;br /&gt;&lt;br /&gt;For Each obj In Application.CurrentProject.AllForms&lt;br /&gt;&lt;br /&gt;If obj.Name &lt;&gt; "Your Form" Then &lt;br /&gt;&lt;br /&gt;DoCmd.Close acForm, obj.name, acSaveYes&lt;br /&gt;&lt;br /&gt;End if &lt;br /&gt;Next obj&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 26 Apr 2007 17:56:19 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3911</guid>
      <author>melissa68 (Melissa )</author>
    </item>
    <item>
      <title>Detect a field edit in Excel and refresh a Query</title>
      <link>http://snippets.dzone.com/posts/show/3613</link>
      <description>&lt;code&gt;&lt;br /&gt;Private Sub Worksheet_Change(ByVal Target As Range)&lt;br /&gt;    Dim wks As Worksheet&lt;br /&gt;    Set wks = ActiveSheet&lt;br /&gt;&lt;br /&gt;    If Target.Row = 1 And Target.Column = 1 Then&lt;br /&gt;      wks.QueryTables(1).Refresh&lt;br /&gt;    End If&lt;br /&gt;&lt;br /&gt;    Set wks = Nothing&lt;br /&gt;End Sub&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 02 Mar 2007 04:29:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3613</guid>
      <author>davetrane (David Davis)</author>
    </item>
  </channel>
</rss>
