<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>vba &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/vba/</link>
	<description>Feed of posts on WordPress.com tagged "vba"</description>
	<pubDate>Mon, 06 Oct 2008 23:28:58 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[How to Finish Our Access And Outlook Data Management Tool]]></title>
<link>http://accesstips.wordpress.com/?p=240</link>
<pubDate>Mon, 06 Oct 2008 22:43:47 +0000</pubDate>
<dc:creator>Patrick Wood</dc:creator>
<guid>http://accesstips.ar.wordpress.com/2008/10/06/how-to-finish-our-access-and-outlook-data-management-tool/</guid>
<description><![CDATA[
With this article we will complete our Appointment Dialog Form that will give us more choices and m]]></description>
<content:encoded><![CDATA[<p><span style="font-size:10pt;font-family:Verdana;background:#FFFFFF;"><br />
With this article we will complete our <strong>Appointment Dialog Form</strong> that will give us more choices and more powerful ways to manage both our Access and Outlook data. We are transforming it into something far better than just a Date Dialog Form.&#160; You will also learn new and important methods of managing data with Access.</p>
<p><strong>1 ) Provide instructions for the user.</strong></p>
<p>If others will be using our Dialog Form they may need some guidance. When you first open the Form there is no way for a user to know the right place to start. We can show a short message when the form first opens by adding the message on a Label. Add the Label as shown in the next image and type in some instructions on the Label. We have set the back color to draw the user's attention immediately. Name the Label <strong>"lblStartInfo"</strong>. Next, open the Label's Properties, click on the "Format" tab and set the "Visible" Property to "No". Then add the following code to the <strong>Form's On Current Event:</strong></p>
<table summary="Code" style="font-size:10pt;background:#e7e7ff;width:100%;">
<tbody>
<tr>
<td style="width:100%;"><font face="Courier New"><br><br />
Private Sub Form_Current()<br><br />
&#160;&#160;&#160;&#160;If Len(Me.txtDateSelection &#38; vbNullString) = 0 Then<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Me.lblStartInfo.Visible = True<br><br />
&#160;&#160;&#160;&#160;Else<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Me.lblStartInfo.Visible = False<br><br />
&#160;&#160;&#160;&#160;End If<br><br />
End Sub<br><br />
<br></font></td>
</tr>
</tbody>
</table>
<p>If a date has not been chosen the txtDateSelection TextBox will be empty. Since selecting a date is the first step in using our Dialog Form our code will make the label visible when the Form opens but invisible when a date has been selected. We need to move the "Export By Dates" Button over to make some room. When our Form is opened it should look like this:</p>
<p>        <img src="http://gainingaccess.net/Images/datedialog11.gif" alt="View of the Form modifications."><br />
    <br><br />
<br></p>
<div dir="ltr" style="margin-right:0;" align="left">
        <strong>2 ) Add a Button to clear the Form.</strong>
    </div>
<p>Providing a way to clear the Form and start over would be helpful and it is not hard to do. Add a Button on the right side of our information label and name it <strong>"btnClearAll"</strong>. Add the following code to the Button's On Click Event:</p>
<table summary="Code" style="font-size:10pt;background:#e7e7ff;width:100%;">
<tbody>
<tr>
<td style="width:100%;"><font face="Courier New"><br><br />
Private Sub btnClearAll_Click()<br><br />
' Clear all controls on the Form<br><br />
&#160;&#160;&#160;&#160;Me.txtDateSelection = vbNullString<br><br />
&#160;&#160;&#160;&#160;Me.txtOneDate = vbNullString<br><br />
&#160;&#160;&#160;&#160;Me.txtStartDate = vbNullString<br><br />
&#160;&#160;&#160;&#160;Me.txtEndDate = vbNullString<br><br />
&#160;&#160;&#160;&#160;Me.cboDateRanges = vbNullString<br><br />
&#160;&#160;&#160;&#160;Me.tglSelectAll = False<br><br />
&#160;&#160;&#160;&#160;Me.lstAppointments.RowSource = vbNullString<br><br />
&#160;&#160;&#160;&#160;Me.lstAppointments.Requery<br><br />
&#160;&#160;&#160;&#160;Me.lblStartInfo.Visible = False<br><br />
&#160;&#160;&#160;&#160;Me.chkBusiness = False<br><br />
&#160;&#160;&#160;&#160;Me.chkHolidays = False<br><br />
&#160;&#160;&#160;&#160;Me.chkOther = False<br><br />
&#160;&#160;&#160;&#160;Me.chkPersonal = False<br><br />
<br><br />
End Sub<br><br />
<br></font></td>
</tr>
</tbody>
</table>
<p><br></p>
<p>        <img src="http://gainingaccess.net/Images/datedialog12.gif" alt="View of the Form modifications."></p>
<p><strong>3 ) Add a Button to add all selected Appointments to Outlook.</strong></p>
<p>Place the Button as shown in the image above and set the Caption to <strong>"Export Selections to Outlook"</strong>. Name the Button <strong>"cmdLstBoxToOutlook"</strong>.</p>
<p><strong>4 ) Enter the code to add all selected Appointments to Outlook.</strong></p>
<p>Now we get to add some interesting code. The code has plenty of comments to help you understand what it is doing. This code will get the ID of all the selected Appointments in the ListBox, build a SQL string, use it to open a Recordset, add all of the Appointment information to Outlook, set "Added to Outlook" to True, and then tell us how many Appointments were added to Outlook.</p>
<table summary="Code" style="font-size:10pt;background:#e7e7ff;width:100%;">
<tbody>
<tr>
<td style="width:100%;"><font face="Courier New"><br><br />
Private Sub cmdLstBoxToOutlook_Click()<br><br />
<br><br />
&#160;&#160;&#160;&#160;Dim db As DAO.Database<br><br />
&#160;&#160;&#160;&#160;Dim rst As DAO.Recordset<br><br />
&#160;&#160;&#160;&#160;Dim strSQL As String<br><br />
&#160;&#160;&#160;&#160;Dim strWhere As String<br><br />
<br><br />
&#160;&#160;&#160;&#160;' This variable will be used to tell us how<br><br />
&#160;&#160;&#160;&#160;' many Appointments were added to Outlook<br><br />
&#160;&#160;&#160;&#160;Dim intCount As Integer<br><br />
<br><br />
&#160;&#160;&#160;&#160;' This variable will be used in<br><br />
&#160;&#160;&#160;&#160;' Looping through the ListBox<br><br />
&#160;&#160;&#160;&#160;Dim i As Integer<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Use late binding to avoid the "Reference" issue<br><br />
&#160;&#160;&#160;&#160;Dim olApp As Object 'Outlook.Application<br><br />
&#160;&#160;&#160;&#160;Dim olAppt As Object 'olAppointmentItem<br><br />
<br><br />
&#160;&#160;&#160;&#160;If isAppThere("Outlook.Application") = False Then<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Outlook is not open, create a new instance<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Set olApp = CreateObject("Outlook.Application")<br><br />
&#160;&#160;&#160;&#160;Else<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Outlook is already open--use this method<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Set olApp = GetObject(, "Outlook.Application")<br><br />
&#160;&#160;&#160;&#160;End If<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Build the first part of a SQL String that will include<br><br />
&#160;&#160;&#160;&#160;' all of the Appointments selected in the ListBox<br><br />
&#160;&#160;&#160;&#160;strSQL = "SELECT tblAppointments.* FROM tblAppointments "<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Start the first part of the SQL "WHERE" String<br><br />
&#160;&#160;&#160;&#160;' The "WHERE" String will hold the Database Appointment ID<br><br />
&#160;&#160;&#160;&#160;' Use the "IN" Predicate to make building the SQL easier<br><br />
&#160;&#160;&#160;&#160;strWhere = "WHERE tblAppointments.ApptmntID IN("<br><br />
<br><br />
<br></font></td>
</tr>
</tbody>
</table>
<p>We build the SQL "WHERE" String by using a Loop to go through all rows in the ListBox and get the ApptmntID of the rows that have been selected. The ListBox contains an <b>Array</b>. An Array is basically data that is arranged and defined in a specific manner. It can consist of just a list of items, but is usually arranged in rows and columns like the Appointments in our ListBox.</p>
<p>Because an Array's dimensions are known, we can easily get specific data from our ListBox. A ListBox Array has a 0 based index. That means the index number of the first item in our ListBox is 0. We will use code to Loop through every Row in the ListBox starting at 0 until the last index number is reached. We use the ListCount Property to know when to stop looping. We need to subtract 1 from our ListCount because ListCount started at 1 instead of 0. This is done in our code like this: <font face="Courier New">For i = 0 To Me.lstAppointments.ListCount - 1.</font></p>
<p>Now we know how to get a specific Row using the variable "i". But getting the Row is not enough. We need to get the ID number of each Appointment selected. We do this by using the Column Property. Each Row in the ListBox contains Columns. Our ID information is in the first Column. The Columns are also 0 based so our code is <font face="Courier New">".Column(0, i)"</font>. The "0" indicates the first Column in the Row and the "i" is our Row's index number.</p>
<p>We want our "WHERE" String to look like this <font face="Courier New">...IN(3, 14, 26)</font>. We must separate our ID numbers with a comma, which our code adds at the end of this line: <font face="Courier New">strWhere = strWhere &#38; lstAppointments.Column(0, i) &#38; ", "</font>. So our code will loop through the rows in the ListBox getting the value of the first Column of all rows that are selected, and separate the ID numbers with commas and a space.</p>
<table summary="Code" style="font-size:10pt;background:#e7e7ff;width:100%;">
<tbody>
<tr>
<td style="width:100%;"><font face="Courier New"><br><br />
' Run the Loop adding a comma , between the ID numbers<br><br />
For i = 0 To Me.lstAppointments.ListCount - 1<br><br />
&#160;&#160;&#160;&#160;If lstAppointments.Selected(i) Then<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;strWhere = strWhere &#38; _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;lstAppointments.Column(0, i) &#38; ", "<br><br />
&#160;&#160;&#160;&#160;End If<br><br />
Next i<br><br />
<br><br />
' Remove the last comma and enclose with a Parenthesis<br><br />
strWhere = Left(strWhere, Len(strWhere) - 2) &#38; ");"<br><br />
<br><br />
' Put the whole SQL Statement together<br><br />
strSQL = strSQL &#38; strWhere<br><br />
<br></font></td>
</tr>
</tbody>
</table>
<p>At this point as the code runs our completed strSQL statement will look like this:<br />
<font face="Courier New">strSQL = SELECT tblAppointments.* FROM tblAppointments WHERE tblAppointments.ApptmntID IN(10, 12, 16);</font></p>
<p>We will use our strSQL to open a Recordset which will only contain the Appointments that have been selected. Then we will then loop through those Appointments, creating a new Appointment in Outlook with each loop.</p>
<table summary="Code" style="font-size:10pt;background:#e7e7ff;width:100%;">
<tbody>
<tr>
<td style="width:100%;"><font face="Courier New"><br><br />
&#160;&#160;&#160;&#160;' Set a Reference to the CurrentDb<br><br />
&#160;&#160;&#160;&#160;Set db = CurrentDb()<br><br />
&#160;&#160;&#160;&#160;' Create a Recordset based on strSQL<br><br />
&#160;&#160;&#160;&#160;Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Begin a Loop through the Recordset<br><br />
&#160;&#160;&#160;&#160;' Move to the first Record<br><br />
&#160;&#160;&#160;&#160;rst.MoveFirst<br><br />
&#160;&#160;&#160;&#160;' Loop to the End of the Recordset<br><br />
&#160;&#160;&#160;&#160;Do Until rst.EOF<br><br />
<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Create a New Outlook Appointment Item<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' with each loop through the Recordset<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' 1 is an olAppointmentItem<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Set olAppt = olApp.CreateItem(1)<br><br />
<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Add the data to the Appointment Properties<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;With olAppt<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Set the Appointment Property Values<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Start = Nz(rst!ApptDate) &#38; " " &#38; _<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Nz(rst!ApptTime, vbNullString)<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.End = Nz(rst!EndDate) &#38; " " &#38; _<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Nz(rst!EndTime, vbNullString)<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Duration = Nz(rst!ApptLength, 0)<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Subject = Nz(rst!Appt)<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Body = Nz(rst!ApptNotes)<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Location = Nz(rst!Location)<br><br />
<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If rst!ApptReminder = True Then<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If rst!ApptDate &#60; Now() Then<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Do Nothing no Reminder is needed<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Else<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If Not IsNull(rst!ReminderMinutes) Then<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.ReminderOverrideDefault = True<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.ReminderMinutesBeforeStart = _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rst!ReminderMinutes<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.ReminderSet = True<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End If<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End If<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End If<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Add the Category if it exists<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Categories = Nz(rst!Categories)<br><br />
<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Save the Appointment Item Properties<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Save<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End With<br><br />
<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Use intCount to count the Appointments added<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;intCount = intCount + 1<br><br />
<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Set the AddedToOutlook Database Field to True<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rst.Edit<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rst!AddedToOutlook = -1 ' True<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rst.Update<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rst.MoveNext<br><br />
&#160;&#160;&#160;&#160;Loop<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Release the Outlook object variables.<br><br />
&#160;&#160;&#160;&#160;Set olAppt = Nothing<br><br />
&#160;&#160;&#160;&#160;Set olApp = Nothing<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Inform the user<br><br />
&#160;&#160;&#160;&#160;MsgBox intCount &#38; _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;" Appointments were added to Outlook.", _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;vbInformation<br></p>
<p><br><br />
End Sub<br><br />
<br></font></td>
</tr>
</tbody>
</table>
<p>We can now select individual Appointments in our ListBox and add them to Outlook. But what if an Appointment is canceled and we need to delete it? We can do that.</p>
<p><strong>5 ) Add a Button to Delete selected Appointments in our Access Database.</strong></p>
<p>Place the <strong>"Delete Selections"</strong> Button on the Form according to the image below and add an appropriate caption. Name the Button <strong>"cmdDeleteSelected"</strong>.</p>
<p>        <img src="http://gainingaccess.net/Images/datedialog13.gif" alt="View of the Form modifications."><br />
    <br></p>
<p><strong>6 ) Enter the code to Delete the Access Database Appointments we select.</strong></p>
<p>It is important to understand that this will delete our Appointments in our Database but not in the Outlook Calendar. We will use the MsgBox as a reminder. Most of the remaining code we have examined previously and it needs no further comment except for one very important line of code, which we will examine.</p>
<table summary="Code" style="font-size:10pt;background:#e7e7ff;width:100%;">
<tbody>
<tr>
<td style="width:100%;"><font face="Courier New"><br><br />
Private Sub cmdDeleteSelected_Click()<br><br />
<br><br />
&#160;&#160;&#160;&#160;Dim db As DAO.Database<br><br />
&#160;&#160;&#160;&#160;Dim strSQL As String<br><br />
&#160;&#160;&#160;&#160;Dim strWhere As String<br><br />
&#160;&#160;&#160;&#160;' Declare a Variable to use to show<br><br />
&#160;&#160;&#160;&#160;' how many records were deleted.<br><br />
&#160;&#160;&#160;&#160;Dim lngRecDeleted As Long<br><br />
&#160;&#160;&#160;&#160;Dim i As Integer<br><br />
<br><br />
&#160;&#160;&#160;&#160;Select Case MsgBox("This action will delete the " &#38; _<br> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;" selected Appointments from your Access Database. " _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#38; vbCrLf &#38; "" _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#38; vbCrLf &#38; " Are you sure you want to" &#38; _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;" permanently delete these Appointments?" _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;, vbYesNo Or vbExclamation Or vbDefaultButton2, _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;"Delete Database Records?")<br><br />
<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Case vbYes<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Let the code continue<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Case vbNo<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;MsgBox "Deletion has been cancelled! ", _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;vbInformation<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Exit Sub<br><br />
&#160;&#160;&#160;&#160;End Select<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Build a SQL Statement to Delete the Selected Appointments<br><br />
&#160;&#160;&#160;&#160;strSQL = "DELETE tblAppointments.* FROM tblAppointments "<br><br />
&#160;&#160;&#160;&#160;strWhere = "Where tblAppointments.ApptmntID IN("<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Loop through the ListBox and gather the data<br><br />
&#160;&#160;&#160;&#160;For i = 0 To Me.lstAppointments.ListCount - 1<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If lstAppointments.Selected(i) Then<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;strWhere = strWhere &#38; _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;lstAppointments.Column(0, i) &#38; ", "<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End If<br><br />
&#160;&#160;&#160;&#160;Next i<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Complete the end of Where Statement<br><br />
&#160;&#160;&#160;&#160;strWhere = Left(strWhere, Len(strWhere) - 2) &#38; ");"<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Put all the SQL together<br><br />
&#160;&#160;&#160;&#160;strSQL = strSQL &#38; strWhere<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Set a Reference to the CurrentDb<br><br />
&#160;&#160;&#160;&#160;Set db = CurrentDb()<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Delete the Selections but Rollback<br><br />
&#160;&#160;&#160;&#160;' the deletions if there is an error.<br><br />
&#160;&#160;&#160;&#160;db.Execute strSQL, dbFailOnError<br><br />
<br><br />
&#160;&#160;&#160;&#160;' Inform the user<br><br />
&#160;&#160;&#160;&#160;lngRecDeleted = db.RecordsAffected<br><br />
&#160;&#160;&#160;&#160;MsgBox lngRecDeleted &#38; _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;" Appointments were Deleted from the Database.", _<br><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;vbInformation<br><br />
<br><br />
End Sub<br><br />
<br></font></td>
</tr>
</tbody>
</table>
<p>Most of the code here we have seen previously. However, the line of code that actually did the work is an important snippet of code that we should discuss.</p>
<p>That important line of code is <font face="Courier New">db.Execute strSQL, dbFailOnError</font>. The <font face="Courier New">Execute</font> Method, when coupled with the <font face="Courier New">dbFailOnError</font> Constant protects our data by rolling back the SQL's changes if there are any errors executing the SQL. Our Database ends up exactly the same as it was before the Rollback. This is especially important if you are doing payroll or taxes!</p>
<p>If you have followed these articles and completed your Appointment Dialog Form then you have a valuable tool that can increase your productivity and save time. Even more important is the knowledge and ability you have gained. This Dialog Form handled our Appointments in our Access Database. Our next Dialog Form will help us manage our Appointments in <em>Outlook.</em></p>
<p>To <b>download the code</b> used in this article visit our <a href="http://gainingaccess.net">Gaining Access Website.</a>  While you are there, you can download the <strong>Free Access Pop-up Calendar</strong>--the easiest calendar I have ever used. It has no "Reference" problems because it is an Access Form.</p>
<p>Find out how you can <b>get the full Appointment Management Database <a href="http://gainingaccess.net/Membership/GetTotalAccess.aspx">here</a></b>.</p>
<p>Here is how our Appointment Dialog Form appears now:<br />
<br />
[caption id="attachment_231" align="alignnone" width="500" caption="Our Completed Appointment Dialog Form"]<a href="http://accesstips.files.wordpress.com/2008/10/datedialog10small.jpg"><img src="http://accesstips.wordpress.com/files/2008/10/datedialog10small.jpg" alt="Our Completed Appointment Dialog Form" title="datedialog10small" width="500" height="310" class="size-full wp-image-231" /></a>[/caption]<br />
<br />
Happy computing,<br />
Patrick (Pat) Wood<br />
<a href="http://gainingaccess.net">Gaining Access</a><br />
<a href="http://www.churchmanagesoftware.com">Church Management Software Solutions</a><br />
</span><br />
<br><br />
<a href="http://technorati.com/faves?sub=addfavbtn&#38;add=http://advenet.com/hunter57/blog/default.aspx"><img src="http://static.technorati.com/pix/fave/tech-fav-1.png" alt="Add to Technorati Favorites" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Tortoise SVN Client Side Hook Scripts]]></title>
<link>http://sfalla.wordpress.com/?p=10</link>
<pubDate>Mon, 06 Oct 2008 21:00:50 +0000</pubDate>
<dc:creator>sfalla</dc:creator>
<guid>http://sfalla.ar.wordpress.com/2008/10/06/tortoise-svn-client-side-hook-scripts/</guid>
<description><![CDATA[As of version 1.5 of TortoiseSVN, several new features have been included relating to the integratio]]></description>
<content:encoded><![CDATA[<p>As of version 1.5 of TortoiseSVN, several new features have been included relating to the integration of issue trackers with the client.</p>
<p>The main part of the integration allows for the addition of structured  issue numbers to a commit log that allows for reference back to an issue tracker.</p>
<p>Details of this can be found here <a title="tsvn-dug-bugtracker" href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-bugtracker.html" target="_blank">http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-bugtracker.html</a></p>
<p>The second part of the integration is to update the issue tracker itself. Normally this would be done with a server side hook script on the SVN server itself, of which there are many examples out there already.</p>
<p><!--more--></p>
<p>I was unable to use this method though, as our issue tracker is in an Access Database on a Windows network share, but the subversion server is on a linux server.</p>
<p>I had looked at <a title="dbtcp" href="http://www.fastflow.it/dbftp/" target="_blank">http://www.fastflow.it/dbftp/</a> and also <a title="MdbDriver" href="http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Id=2959&#38;Path=SRC680%2Fmdbdriver02" target="_blank">http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Id=2959&#38;Path=SRC680%2Fmdbdriver02</a>, but setting this up seemed a bit too much effort for something so simple.</p>
<p>The alternative was provided by client side hook scripts in tortoisesvn.</p>
<p><a title="Tortoise SVN Hooks" href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-settings.html#tsvn-dug-settings-hooks" target="_blank">http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-settings.html#tsvn-dug-settings-hooks</a></p>
<p>So here is my example of how to implement client side hook scripts to integrate tortoise svn with an Access based Issue Tracker. It could easily be modified to integrate with other types of databases.</p>
<p>I should point out at this point that these scripts were heavily inspired by the server side scripts at <a title="www.FogBugz.com" href="http://www.fogcreek.com/FogBugz/" target="_blank">Fogbugz</a> who have done a lot of work integrating different source control systems together and seemed to be heavily involved in the specification for inserting structured bug ids into subversion commit messages, detailed earlier.</p>
<p>First of all, a simple batch file is needed as it needs to be executable by Windows. This in turn calls a vbscript that has more functionality.</p>
<p><strong>post-commit.bat</strong></p>
<blockquote><p>@echo off<br />
rem TortoiseSVN Client Side post-commit hook script<br />
rem Put this into a Hooks folder on your workstation<br />
rem with the accompanying vbs script<br />
rem<br />
rem Tortoise SVN will call this script with the following parameters<br />
rem after the commit action<br />
rem<br />
rem script &#60;Path&#62; &#60;Depth&#62; &#60;MessageFile&#62; &#60;Revision&#62; &#60;Error&#62;</p>
<p>setlocal</p>
<p>set tsvnPath=%1<br />
set tsvnDepth=%2<br />
set tsvnMsgFile=%3<br />
set tsvnRevision=%4<br />
set tsvnError=%5<br />
set tsvnCwd=%6</p>
<p>rem This gets the path of the script being called so that the vbs script<br />
rem can be referenced correctly, as the script is run from a different working folder<br />
set tsvnHookScriptPath=%~dp0</p>
<p>set tsvnPostCommitScript=post-commit.vbs<br />
set tsvnHookScriptFinalPath="%tsvnHookScriptPath:"=%%tsvnPostCommitScript:"=%"</p>
<p>rem echo Path %tsvnPath% &#62;&#62; c:\tsvnLog.txt<br />
rem echo Depth %tsvnDepth% &#62;&#62; c:\tsvnLog.txt<br />
rem echo MsgFile %tsvnMsgFile% &#62;&#62; c:\tsvnLog.txt<br />
rem echo Revision %tsvnRevision% &#62;&#62; c:\tsvnLog.txt<br />
rem echo Error %tsvnError% &#62;&#62; c:\tsvnLog.txt<br />
rem echo Cwd %tsvnCwd% &#62;&#62; c:\tsvnLog.txt</p>
<p>type %tsvnMsgFile% &#124; cscript %tsvnHookScriptFinalPath% %tsvnRevision%</p>
<p>endlocal</p></blockquote>
<p><strong>post-commit.vbs</strong></p>
<blockquote><p>' Update this to be the same as the svn property bugtraq:message without the %BUGID% part<br />
Const cstrIssuePrefix = "Issue: "</p>
<p>' Set this to the location of the access database<br />
Const cstrIssueDB = "C:\Issuetracker.mdb"</p>
<p>Dim strCommitLog<br />
Dim tsvnRevisionID<br />
Dim args<br />
Dim re<br />
Dim matches<br />
Dim match<br />
Dim strIssueID<br />
Dim lngIssueID<br />
Dim strIssues<br />
Dim i<br />
Dim arrIssues<br />
Dim dbConn<br />
Dim dbCommand<br />
Dim dbConnString<br />
Dim rs<br />
Dim strSQL<br />
Dim lng</p>
<p>' Get the revision ID of the subversion commit<br />
Set args = WScript.Arguments.UnNamed<br />
tsvnRevisionID = args(0)</p>
<p>' Read the commit log from STDIN<br />
strCommitLog = WScript.StdIn.ReadAll</p>
<p>' Search for any reference to the issue ID in the commit log<br />
Set re = New RegExp<br />
re.IgnoreCase = True<br />
re.Global = True<br />
re.Pattern = "\s*Task[#:; ]+((\d+[ ,:;#]*)+)"</p>
<p>Dim bugIDString: bugIDString = ""</p>
<p>Set matches = re.Execute(strCommitLog)<br />
If matches.Count &#62; 0 Then<br />
For i = 0 To (matches.Count - 1)<br />
Set match = matches(i)<br />
strIssues = strIssues &#38; match.SubMatches(0)<br />
Next<br />
' strip any trailing comma<br />
strIssues = Left(strIssues, Len(strIssues) -1)<br />
Else<br />
WScript.Quit 0<br />
End If</p>
<p>arrIssues = split(strIssues, ",")</p>
<p>dbConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" &#38; cstrIssueDB &#38; ";"<br />
Set dbConn=CreateObject("ADODB.Connection")<br />
Set dbCommand =CreateObject("ADODB.Command")</p>
<p>dbConn.open dbConnString<br />
dbCommand.ActiveConnection = dbConn<br />
For Each strIssueID in arrIssues<br />
If IsNumeric(strIssueID) Then<br />
lngIssueID = CLng(strIssueID)<br />
strSQL = "UPDATE tblIssues SET [issueLog] = '" &#38; Date &#38; " " &#38; Time &#38; " Updated in SVN using revision " &#38; tsvnRevisionID &#38; vbCrLf &#38; vbCrLf &#38; "' + [issueLog] WHERE [issueID] = " &#38; lngIssueID<br />
cmd.CommandText = strSQL<br />
Set rs = dbCommand.Execute<br />
End If<br />
Next<br />
dbConn.Close</p></blockquote>
<p><strong>What Next</strong></p>
<p>Well watch this space as I would like to develop a generic COM object that will allow even further integration with Tortoise SVN wo allow for selection of open issues from an access database as well. See <a title="Integration with Issue Tracker" href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-bugtracker.html#tsvn-dug-bugtracker-ref">here</a> for details.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Clear Controls on Userform]]></title>
<link>http://socko.wordpress.com/?p=311</link>
<pubDate>Mon, 06 Oct 2008 13:44:23 +0000</pubDate>
<dc:creator>selvavpasupathy</dc:creator>
<guid>http://socko.ar.wordpress.com/2008/10/06/clear-controls-on-userform/</guid>
<description><![CDATA[- Selva V Pasupathy, HSBC Global Resourcing, Hyderabad
The following code can be used to clear all t]]></description>
<content:encoded><![CDATA[<p>- Selva V Pasupathy, HSBC Global Resourcing, Hyderabad<br />
The following code can be used to clear all textboxes and comboboxes on userform. </p>
<p><code>
<pre>
Private Sub Clear_all()
    For I = 0 To UserForm1.Controls.Count - 1

        If UCase(TypeName(UserForm1.Controls(I))) = "TEXTBOX" Then
            UserForm1.Controls(I).Value = ""
        End If
        If UCase(TypeName(UserForm1.Controls(I))) = "COMBOBOX" Then
            UserForm1.Controls(I).Value = ""
        End If
    Next I
End Sub
</pre>
<p></code></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Referring To Named Ranges]]></title>
<link>http://excelling.wordpress.com/?p=49</link>
<pubDate>Sat, 04 Oct 2008 15:00:22 +0000</pubDate>
<dc:creator>parkercpa</dc:creator>
<guid>http://excelling.ar.wordpress.com/2008/10/04/referring-to-named-ranges/</guid>
<description><![CDATA[Excel&#8217;s VBA help file goes into referring to named ranges without much discussion on how to na]]></description>
<content:encoded><![CDATA[<p>Excel's VBA help file goes into referring to named ranges without much discussion on how to name a range.  Most people who have used excel for some time know how to name a range. On the off chance you don't, one of the easiest ways is to select the area that will now be know by the 'name' and type that name in the name box which is located just to the left of the formula bar as shown by the arrow in the illustration below.</p>
<p><a href="http://excelling.files.wordpress.com/2008/10/excel11.jpg"><img class="aligncenter size-full wp-image-51" title="excel11" src="http://excelling.wordpress.com/files/2008/10/excel11.jpg" alt="" width="593" height="409" /></a></p>
<p>I'm certainly no expert in writing VBA code and get most of my coding done by recording macros. One thing I've noticed about Excel (at least in version 2003) is that when recording macros, it does not seem to like you naming ranges in this way.  So when I need to name a range while recording a macro I will name a range using another method. That way is by selecting the Insert menu and chosing Name --&#62; Define.  The resulting dialog box allows you to name the range and even tweak it somewhat in the 'refers to' section of the dialog box. I haven't ever had much of a need to tweak it, but I've seen some pretty cool stuff done to make the range dynamic in nature. Perhaps one day I'll research that and do a post on it.  By defining a range in this way, Excel writes the following code:</p>
<p>[sourcecode language='vb']</p>
<p>ActiveWorkbook.Names.Add Name:="test", RefersToR1C1:="=Sheet1!R7C3:R17C4"</p>
<p>[/sourcecode]</p>
<p>In this case I've used the name <em>test </em>to describe the range C7 through D17.  I'm certain there are plenty of other ways to define a range of cells, but for a beginner this is the easiest, plus you can let the macro do the heavy lifting for you.</p>
<p>Once you've defined a range it is easy later in the code to refer to that range by simply referring to the name instead of referring to the actual cells. For example if you wanted to return to the range to make it bold you could use the following code:</p>
<p>[sourcecode language='vb']</p>
<p>Application.Goto Reference:="test"<br />
    Selection.Font.Bold = True</p>
<p>[/sourcecode]</p>
<p>If the range you are referring to is in another workbook you can simply add the workbook name within the quotes like such:</p>
<p>[sourcecode language='vb']</p>
<p>Application.Goto Reference:="Workbook.xls!Test"<br />
     Selection.ClearContents</p>
<p>[/sourcecode]</p>
<p>That's pretty basic and doesn't go beyond doing anything with the range once you've referred to it, but I'll save that for another post.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Destacar a linha selecionada alterando a cor de fundo]]></title>
<link>http://exceldoseujeito.wordpress.com/?p=6</link>
<pubDate>Sat, 04 Oct 2008 00:28:49 +0000</pubDate>
<dc:creator>exceldoseujeito</dc:creator>
<guid>http://exceldoseujeito.ar.wordpress.com/2008/10/04/destacar-a-linha-selecionada-alterando-a-cor-de-fundo/</guid>
<description><![CDATA[Esse código destaca toda a  linha onde há a célula ativa no momento, alterando sua cor de fundo. ]]></description>
<content:encoded><![CDATA[<p>Esse código destaca toda a  linha onde há a célula ativa no momento, alterando sua cor de fundo. Toda vez  que uma célula receber o foco, a linha toda ficará realçada e ao sair dela,  voltará ao normal.</p>
<p>Um detalhe, é que, foi  criada uma condição para excluir as linhas cuja formatação de fundo não poderia  ser alterada, como por exemplo, uma linha que contenha um título e já esteja  com um padrão de fundo definido de forma diferenciada.</p>
<p>Vamos ao código.</p>
<p>No módulo de classe da <em>Plan1</em>, declare, na seção Geral do mesmo,  a variável <strong>LinhaSelecAnterior,</strong> pois  ela ficará acessível a toda a Plan1.</p>
<p>Digite o seguinte código:</p>
<p style="padding-left:30px;">Dim LinhaSelecAnterior As Range</p>
<p style="padding-left:30px;">Private Sub Worksheet_SelectionChange(ByVal Target As Range)</p>
<p style="padding-left:60px;">Select Case ActiveCell.Row</p>
<p style="padding-left:90px;">Case 1, 2<br />
<span style="color:#008000;">'Coloque neste 'case' as linhas que não devem ser<br />
'destacadas na seleção<br />
'Exemplo: Linhas de título; Aqui eu defini como as linhas 1 e 2</span></p>
<p style="padding-left:120px;"><span style="color:#008000;">'Remove cor de fundo da linha selecionada anteriormente</span><br />
Select Case LinhaSelecAnterior.Row</p>
<p style="padding-left:150px;">Case Is &#60;&#62; 1, 2</p>
<p style="padding-left:180px;">Rows(LinhaSelecAnterior.Row).Interior.ColorIndex = 0</p>
<p style="padding-left:120px;">End Select</p>
<p style="padding-left:90px;">Case Else</p>
<p style="padding-left:120px;"><span style="color:#008000;">'Altera a cor de fundo da linha selecionada</span><br />
Rows(ActiveCell.Row).Interior.ColorIndex = 15</p>
<p style="padding-left:120px;"><span style="color:#008000;">'Remove a cor de fundo quando a linha perde a seleção</span><br />
If Not LinhaSelecAnterior Is Nothing Then</p>
<p style="padding-left:150px;"><span style="color:#008000;">'Verifica se a linha atual já estava selecionada<br />
'neste momento, caso seja uma nova linha selecionada<br />
'remove a cor de fundo.</span><br />
If ActiveCell.Row &#60;&#62; LinhaSelecAnterior.Row Then</p>
<p style="padding-left:180px;">Rows(LinhaSelecAnterior.Row).Interior.ColorIndex = 0</p>
<p style="padding-left:150px;">End If</p>
<p style="padding-left:120px;">End If</p>
<p style="padding-left:120px;"><span style="color:#008000;">'Inicializa a variavel informando a seleção atual<br />
'que será utilizada no inicio do procedimento<br />
'como sendo a seleção anterior</span><br />
Set LinhaSelecAnterior = ActiveCell</p>
<p style="padding-left:60px;">End Select</p>
<p style="padding-left:30px;">End Sub</p>
<p>Salve e Encerre o ambiente  do VBA</p>
<p>Pronto. Agora quando você  selecionar qualquer célula da Plan1, a linha inteira será destacada das demais.</p>
<p>Termos aprendidos neste  artigo:</p>
<table style="border-collapse:collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="background-color:#CCCCCC;border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="229" valign="top"><strong><span style="text-decoration:underline;">Range</span></strong></td>
<td style="border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="413" valign="top">Retorna um objeto <strong>Range</strong> representando uma única célula ou um intervalo de células.</td>
</tr>
<tr>
<td style="background-color:#CCCCCC;border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="229" valign="top"><strong><span style="text-decoration:underline;">ActiveCell</span></strong></td>
<td style="border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="413" valign="top">Retorna um objeto <strong>Range</strong> representando a célula ativa da janela ativa (a janela visível) ou da janela    especificada. Se a janela não estiver exibindo uma planilha, essa propriedade    falhará. Somente leitura.</td>
</tr>
<tr>
<td style="background-color:#CCCCCC;border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="229" valign="top"><strong><span style="text-decoration:underline;">Row</span></strong></td>
<td style="border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="413" valign="top">Retorna o número da primeira linha da primeira área do    intervalo. <strong>Long</strong> somente leitura.</td>
</tr>
<tr>
<td style="background-color:#CCCCCC;border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="229" valign="top"><strong><span style="text-decoration:underline;">Rows</span></strong></td>
<td style="border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="413" valign="top">Para um objeto <strong>Application</strong>,    retorna um objeto <strong>Range</strong> representando todas as linhas da planilha    ativa. Se o documento ativo não for uma planilha, a propriedade <strong>Rows</strong> falhará. Para um objeto <strong>Range</strong>, retorna um objeto <strong>Range</strong> representando as linhas no intervalo especificado. Para um objeto <strong>Worksheet</strong>,    retorna um objeto <strong>Range</strong> representando todas as linhas da planilha    especificada. Objeto <strong>Range</strong> somente leitura.</td>
</tr>
<tr>
<td style="background-color:#CCCCCC;border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="229" valign="top"><strong><span style="text-decoration:underline;">Interior</span></strong></td>
<td style="border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="413" valign="top">Retorna um objeto <strong>Interior</strong> representando o interior do objeto especificado.</td>
</tr>
<tr>
<td style="background-color:#CCCCCC;border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="229" valign="top"><strong><span style="text-decoration:underline;">ColorIndex</span></strong></td>
<td style="border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="413" valign="top">Retorna ou define a cor    interna. A cor é especificada como um valor de índice na paleta de cores    atual.</td>
</tr>
<tr>
<td style="background-color:#CCCCCC;border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="229" valign="top"><strong><span style="text-decoration:underline;">Worksheet_SelectionChange</span></strong></td>
<td style="border-top-color:#000000;border-top-style:solid;border-top-width:1px;" width="413" valign="top">O Evento <strong>SelectionChange</strong> ocorre quando a seleção é alterada em uma    planilha.</td>
</tr>
</tbody>
</table>
<p>Um abraço a todos.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Интерфейс VBA -&gt; AutoLISP]]></title>
<link>http://tarpacad.wordpress.com/?p=25</link>
<pubDate>Fri, 03 Oct 2008 17:32:19 +0000</pubDate>
<dc:creator>bausk</dc:creator>
<guid>http://tarpacad.ar.wordpress.com/2008/10/03/%d0%b8%d0%bd%d1%82%d0%b5%d1%80%d1%84%d0%b5%d0%b9%d1%81-vba-autolisp/</guid>
<description><![CDATA[ Библиотека для общения с AutoLISP из Бейсика. А также тема ]]></description>
<content:encoded><![CDATA[<p><img class="alignmiddle size-full wp-image-33" style="border:0 none #000000;" title="ru" src="http://tarpacad.wordpress.com/files/2008/10/ru.png" alt="" width="30" height="15" /> Библиотека для общения с AutoLISP из Бейсика. А также тема на форуме (англ.) и пример использования.</p>
<p><a href="http://autolisp-exchange.com/forum/showthread.php?t=63">Vlax.cls for VBA and AutoLISP apps</a></p>
<p>(via <a href="http://dwg.ru/f/member.php?u=28">kpblc</a>)</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[smack]]></title>
<link>http://softwareetc.wordpress.com/?p=13</link>
<pubDate>Wed, 01 Oct 2008 23:12:35 +0000</pubDate>
<dc:creator>softwareetc</dc:creator>
<guid>http://softwareetc.ar.wordpress.com/2008/10/01/smack/</guid>
<description><![CDATA[Earlier today I was writting some vba code (since it was all that was readily available on the compu]]></description>
<content:encoded><![CDATA[<p>Earlier today I was writting some vba code (since it was all that was readily available on the computer that had easy access to retrieving hwnds).</p>
<p>-Consequently, later in the day (in perl mode) i pulled one of these moves:</p>
<p>my @_rst = grep {$_ = $_check} @_previous</p>
<p>Took a bit of debugging to realize that all the items in previous mysteriously became whatever the most recent value of check was.  Ugh, stupid.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[По-хозяйски]]></title>
<link>http://structural.wordpress.com/?p=63</link>
<pubDate>Mon, 29 Sep 2008 10:31:02 +0000</pubDate>
<dc:creator>bausk</dc:creator>
<guid>http://structural.ar.wordpress.com/2008/09/29/%d0%bf%d0%be-%d1%85%d0%be%d0%b7%d1%8f%d0%b9%d1%81%d0%ba%d0%b8/</guid>
<description><![CDATA[&#8230;отделяю все, что касается CAD и программирования, в о]]></description>
<content:encoded><![CDATA[<p>...отделяю все, что касается CAD и программирования, в отдельный журнал про, собственно, Автокад и будущий САПР-пакет для него: <a href="http://tarpacad.wordpress.com">TarpaCAD</a>.</p>
<p>Моя предыдущая разработка, полная глюков и ошибок, исправно отпахала приблизительно на десяти рабочих компьютерах под AutoCAD 2005 больше трех лет. Пора ее наконец заменить.<br />
Это будет что-то с чем-то, если удастся реализовать хотя бы пятую часть всех мыслей.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Easily Save Outlook Appointments In Access With A Custom Dialog Form]]></title>
<link>http://accesstips.wordpress.com/?p=191</link>
<pubDate>Fri, 26 Sep 2008 03:18:46 +0000</pubDate>
<dc:creator>Patrick Wood</dc:creator>
<guid>http://accesstips.ar.wordpress.com/2008/09/25/easily-save-outlook-appointments-in-access-with-a-custom-dialog-form/</guid>
<description><![CDATA[
Today we will make our Appointment Dialog Form very User Friendly. We will be able to Filter and Se]]></description>
<content:encoded><![CDATA[<div><span style="font-size:10pt;font-family:Verdana;"><br />
Today we will make our <strong>Appointment Dialog Form</strong> very User Friendly. We will be able to <em>Filter and Select the exact Appointments we want</em>. First we will add several checkboxes to be used in filtering data and then we will add a Multi-Select ListBox so we can see and select the exact Appointments we want. </p>
<p>We are naming or are renaming our Form <strong>"frmDBApptDialog" for Database Appointment Dialog</strong>. We will have another form later named <strong>"frmOLApptDialog" for Outlook Appointment Dialog</strong>. Here is how our frmDBApptDialog appears so far.<br />
<br></p>
<p><br><br />
<img src="http://gainingaccess.net/Images/datedialog6.jpg" alt="" /></p>
<p><strong>1 ) First we will add 4 CheckBoxes to the Form</strong>.</p>
<p>Open your Form in Design view and place the CheckBoxes below the Date TextBoxes. Adding an informative Label and a Rectangle around them gives the Form a nice look and makes it easier for the user.</p>
<p><img src="http://gainingaccess.net/Images/datedialog8.gif" alt="" /></p>
<p>Enter the Label Captions you see in the image above. Add a name for each of the CheckBoxes in the Properties Sheet under the Tab "Other". Name them according to their Captions:</p>
<p>Label Caption: "Exclude Holidays", CheckBox Name: "chkHolidays"</p>
<p>Label Caption: "Exclude Other", CheckBox Name: "chkOther"</p>
<p>Label Caption: "Exclude Business", CheckBox Name: "chkBusiness"</p>
<p>Label Caption: "Exclude Personal", CheckBox Name: "chkPersonal"</p>
<p><strong>2 ) Add an Unbound ListBox to the Form.</strong> </p>
<p>It should look something like this:<br />
<br />
[caption id="attachment_233" align="alignnone" width="500" caption="Our Form after adding CheckBoxes and a ListBox"]<a href="http://accesstips.files.wordpress.com/2008/10/datedialog9small.jpg"><img src="http://accesstips.wordpress.com/files/2008/10/datedialog9small.jpg" alt="Our Form after adding CheckBoxes and a ListBox" title="datedialog9small" width="500" height="319" class="size-full wp-image-233" /></a>[/caption]<br />
</p>
<p>Name the ListBox "lstAppointments". Copy the following into the RowSource because we do not want to see anything there when the Form is opened: <span style="font-family:Courier New;">SELECT tblAppointments.ApptmntID FROM tblAppointments WHERE ApptmntID = 999999999;</span></p>
<p>Click on the Properties Sheet "Other" tab and in the Multiselect Property select "Extended" from the Drop Down List. This will enable us to select any or all of the Appointments in the ListBox.</p>
<p><strong>3 ) Add the code for each of the CheckBoxes.</strong><br />
</p>
<table style="font-size:10pt;background:#e7e7ff;width:100%;" border="0">
<tbody>
<tr valign="top;">
<td style="width:100%;"><span style="font-family:Courier New;"><br />
Private Sub chkBusiness_AfterUpdate()<br />
    If Len(Me.txtDateSelection &#38; vbNullString) &#62; 0 Then<br />
        OptionsSet<br />
    End If<br />
End SubPrivate Sub chkHolidays_AfterUpdate()<br />
    If Len(Me.txtDateSelection &#38; vbNullString) &#62; 0 Then<br />
        OptionsSet<br />
    End If<br />
End Sub</p>
<p>Private Sub chkOther_AfterUpdate()<br />
    If Len(Me.txtDateSelection &#38; vbNullString) &#62; 0 Then<br />
        OptionsSet<br />
    End If<br />
End Sub</p>
<p>Private Sub chkPersonal_AfterUpdate()<br />
    If Len(Me.txtDateSelection &#38; vbNullString) &#62; 0 Then<br />
        OptionsSet<br />
    End If<br />
End Sub</p>
<p></span></td>
</tr>
</tbody>
</table>
<p></p>
<p><strong>OptionsSet</strong> is a Sub that builds a SQL "Where" Statement that we will use to filter out the dates that we do not want. For example, if you do not want your Personal Appointments in the list they are instatly removed. Each time a CheckBox is clicked the OptionsSet Sub is run and it sets the RowSource for the ListBox and requeries it so the right Appointments appear in the ListBox.</p>
<p><strong>4 ) Add the OptionsSet code.</strong></p>
<p>You can place this sub anywhere in the Form. The first part is the declaration of the SQL string Variables.</p>
<p></p>
<table style="font-size:10pt;background:#e7e7ff;width:100%;" border="0">
<tbody>
<tr valign="top;">
<td style="width:100%;"><span style="font-family:Courier New;"><br />
Private Sub OptionsSet()    Dim strSQLlbx As String ' A SQL Statement for the ListBox.<br />
    Dim strWhere As String ' To build final "Where" Statement<br />
    Dim strWherechk As String ' To filter using the CheckBoxes</p>
<p>    ' This is one way you can build a SQL "Where" Statement<br />
    If Me.chkBusiness = True Then<br />
        strWherechk = strWherechk &#38; ",'Business'"<br />
    End If</p>
<p>    If Me.chkHolidays = True Then<br />
        strWherechk = strWherechk &#38; ",'Holiday'"<br />
    End If</p>
<p>    If Me.chkOther = True Then<br />
        strWherechk = strWherechk &#38; ",'Other'"<br />
    End If</p>
<p>    If Me.chkPersonal = True Then<br />
        strWherechk = strWherechk &#38; ",'Personal'"<br />
    End If</p>
<p>    ' If the first part of strWherechk is a comma: ,<br />
    ' We know that strWherechk has a value to use<br />
    If Left(strWherechk, 1) = "," Then</p>
<p>        ' Remove the comma: ,<br />
        strWherechk = Right(strWherechk, Len(strWherechk) - 1)</p>
<p>        ' Add the beginning part of the Where Statement<br />
        strWherechk = "AND Categories Not In (" &#38; strWherechk</p>
<p>        ' Add the end part of the Where Statement<br />
        strWherechk = strWherechk &#38; ")"<br />
    Else<br />
        ' If the , was not added to strWherechk then<br />
        ' No value was there--clear strWherechk<br />
        strWherechk = vbNullString<br />
    End If</p>
<p>    ' Add the dates that were selected to another "Where" Statement<br />
    strWhere = " WHERE ((tblAppointments.ApptDate)" &#38; _<br />
        " &#62;= [Forms]![frmDBApptDialog]![txtStartDate])" &#38; _<br />
        " AND ((tblAppointments.EndDate)" &#38; _<br />
        "&#60;=[Forms]![frmDBApptDialog]![txtEndDate])"</p>
<p>    ' Put together both of the "Where" Statements.<br />
    strWhere = strWhere &#38; strWherechk</p>
<p>    ' Build the entire SQL Statement<br />
    strSQLlbx = "SELECT tblAppointments.ApptmntID," &#38; _<br />
        " tblAppointments.Appt, tblAppointments.ApptDate," &#38; _<br />
        " tblAppointments.EndDate, tblAppointments.Categories" &#38; _<br />
        " FROM tblAppointments" &#38; _<br />
        strWhere &#38; _<br />
        " ORDER BY tblAppointments.ApptDate DESC;"</p>
<p>    ' Set the ListBox's RowSource to show the Appointments<br />
    Me.lstAppointments.RowSource = strSQLlbx</p>
<p>    ' Requery the ListBox to update the data<br />
    Me.lstAppointments.Requery</p>
<p>End Sub</p>
<p></span></td>
</tr>
</tbody>
</table>
<p></p>
<p>Now we are really getting somewhere! We can filter the Appointments and see the exact Appointments we want to select. Now we can set up some time-saving features.</p>
<p><strong>5 ) Add a Toggle Button to Select all or Deselect all Appointments.</strong><br />
</p>
<p>Open the form in Design View and add a Toggle Button centered directly above the ListBox. Name the Toggle Button "tglSelectAll". On the Button's AfterUpdate Event add the following code:<br />
</p>
<table style="font-size:10pt;background:#e7e7ff;width:100%;" border="0">
<tbody>
<tr valign="top;">
<td style="width:100%;"><span style="font-family:Courier New;"><br />
Private Sub tglSelectAll_AfterUpdate()    ' Declare a Variable to use to select Appointments<br />
    Dim i As Integer</p>
<p>    ' If clicked select all of the Appointments<br />
    If Me.tglSelectAll = True Then</p>
<p>        ' Get a range for the Loop<br />
        ' ListCount gives us the total number of Appointments.<br />
        For i = 1 To lstAppointments.ListCount<br />
            lstAppointments.Selected(i) = True<br />
        Next i</p>
<p>        'Change the Toggle Button Caption to Deselect<br />
        Me.tglSelectAll.Caption = "Deselect All"<br />
    Else</p>
<p>        For i = 1 To lstAppointments.ListCount<br />
            lstAppointments.Selected(i) = False<br />
        Next i</p>
<p>        Me.tglSelectAll.Caption = "Select All"<br />
    End If</p>
<p>End Sub</p>
<p></span></td>
</tr>
</tbody>
</table>
<p></p>
<p>Now we can select the exact Appointments we want in the ListBox. We can select all with one click and then deslect them all.</p>
<p>Our next step is to add code that will process the Appointments. In our next article, we will add the ability to Export the selected Appointments to Outlook or to Delete them from the Database.</p>
<p>To download the code used in this article visit our <a href="http://gainingaccess.net/">Gaining Access Website.</a> While you are there, you can download the <strong>Free Access Pop-up Calendar</strong>--the easiest calendar I have ever used. It has no "Reference" problems because it is an Access Form.</p>
<p>To download the full Appointment Database become a Premium Member with <a href="http://gainingaccess.net/Membership/GetTotalAccess.aspx">Total Access.</a></p>
<p>Here is a preview of the Dialog Form we will complete with our next article:<br />
<br />
[caption id="attachment_231" align="alignnone" width="500" caption="Our Completed Appointment Dialog Form"]<a href="http://accesstips.files.wordpress.com/2008/10/datedialog10small.jpg"><img src="http://accesstips.wordpress.com/files/2008/10/datedialog10small.jpg" alt="Our Completed Appointment Dialog Form" title="datedialog10small" width="500" height="310" class="size-full wp-image-231" /></a>[/caption]<br />
<br />
Happy computing,<br />
Patrick (Pat) Wood<br />
<a href="http://gainingaccess.net">Gaining Access</a><br />
<a href="http://www.churchmanagesoftware.com">Church Management Software Solutions</a><br />
</span><br />
<br />
<a href="http://technorati.com/faves?sub=addfavbtn&#38;add=http://advenet.com/hunter57/blog/default.aspx"><img src="http://static.technorati.com/pix/fave/tech-fav-1.png" alt="Add to Technorati Favorites" /></a></p>
<div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Lesson #1, wherein smug comes undone.]]></title>
<link>http://cathychua.wordpress.com/?p=1023</link>
<pubDate>Thu, 25 Sep 2008 03:48:04 +0000</pubDate>
<dc:creator>cathychua</dc:creator>
<guid>http://cathychua.ar.wordpress.com/2008/09/25/lesson-1-wherein-smug-comes-undone/</guid>
<description><![CDATA[Playing Justin Stark and Martin Willcox at the VBA last night, this hand came up:

Dlr: West
Vul: NS]]></description>
<content:encoded><![CDATA[<p>Playing Justin Stark and Martin Willcox at the VBA last night, this hand came up:</p>
<p><!--more--></p>
<p>Dlr: West<br />
Vul: NS</p>
<table border="0">
<tbody>
<tr>
<td width="125"></td>
<td width="125">NORTH</p>
<p>S J852</p>
<p>H AKJ975</p>
<p>D Q</p>
<p>C K3</td>
</tr>
<tr>
<td>WEST</p>
<p>S Q93</p>
<p>H 3</p>
<p>D K108743</p>
<p>C A107</td>
<td></td>
<td width="125">EAST</p>
<p>S K1076</p>
<p>H Q108</p>
<p>D J2</p>
<p>C Q952</td>
</tr>
<tr>
<td></td>
<td>SOUTH</p>
<p>S A4</p>
<p>H 642</p>
<p>D A965</p>
<p>C J864</td>
</tr>
</tbody>
</table>
<p>West, Martin, passed but then over 1H 2H he backed in with 3D over which 4H ended the auction. Justin began with the jack of diamonds and I won the ace. You can't make unless the club ace is onside. Meanwhile in the majors you are on a guess of sorts. If hearts are 3-1 you can make by taking 2 spade ruffs in dummy, eventually conceding a trump to go with the club and spade tricks. If trumps are 2-2 and East has the queen you need to draw two rounds of trumps, losing 2 spades and a club. If you try to ruff the fourth spade West will be able to win and promote a trump trick via the diamond suit.</p>
<p>Mull over that as you will, you have to do something. I played ace and another spade, West giving count which suggested three. East won that and he could force me to guess how trumps are divided by continuing with a spade or a diamond. Instead, however, he shifted to a club, won by West who reverted to diamonds. Now you are able to find out exactly what shape West is. Ruff the diamond, cash the king of clubs, ruff a spade and play a club off dummy. If West follows, then he has only one heart. If he shows out he has two hearts. As it is, he followed, so I cashed one heart and took the second spade ruff.</p>
<p>I like this hand. It's neat. It gives you that nice feeling you get when you fill in a Sudoku number without guessing. And frankly, I was smugly thinking about it a couple of hands later when I found myself declarer, again in 4H, on the following deal. We're not talking  as smug as smug can be here...more like if it were prefacing a TV show it would say 'Warning, low level smugness. Parental guidance recommended'. About that much smug. Still, it was there and it meant I was thinking about that hand when I should have been thinking about this one:</p>
<table border="0">
<tbody>
<tr>
<td width="125"></td>
<td width="125">NORTH</p>
<p>S AK5</p>
<p>H AKJ1094</p>
<p>D 8</p>
<p>C 742</td>
</tr>
<tr>
<td>WEST</p>
<p>S Q862</p>
<p>H 8765</p>
<p>D AKQ9</p>
<p>C 8</td>
<td></td>
<td width="125">EAST</p>
<p>S 7</p>
<p>H Q2</p>
<p>D J10732</p>
<p>C KQJ103</td>
</tr>
<tr>
<td></td>
<td>SOUTH</p>
<p>S J10943</p>
<p>H 3</p>
<p>D 654</p>
<p>C A954</td>
</tr>
</tbody>
</table>
<p>This time East opened 2N, majors or minors, West tried 4D and I ended matters with 4H. Justin shot out the seven of spades, I covered, West ducked, I hooked a heart, two down. Oh yes, dear reader. I'd just gone down in a coldie, I realised a second later. East's hand is entirely known. 1?55. He can only have two hearts and therefore the only way to make it is to play hearts from the top, hoping the queen is doubleton.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[And my Studies Commence...]]></title>
<link>http://annuca.wordpress.com/?p=181</link>
<pubDate>Tue, 23 Sep 2008 20:16:15 +0000</pubDate>
<dc:creator>annmucc</dc:creator>
<guid>http://annuca.ar.wordpress.com/2008/09/23/and-my-studies-commence/</guid>
<description><![CDATA[After an enjoyable weekend, at last I started doing some research for stuff for my PhD project. Yest]]></description>
<content:encoded><![CDATA[<p>After an enjoyable weekend, at last I started doing some research for stuff for my PhD project. Yesterday I started checking out a bit of what stock modelling is all about and also a bit of visual basic for applications? (VBA) (hmmm, you are probably saying, isn't she a chemistry and biology student and now doing sustainable heritage, so what do these have to do with that?)...Well, my supervisor told me that I should check them out since I will need this knowledge in some aspects of my research. Oh well...we will try. I THINK I got a bit of the hang of what stock modelling is all about...but VBA I am still a bit doubtful O:). We will see how it goes.</p>
<p>Yesterday evening and today I was then looking up stuff about colour photographs, the history, how it developed, and basic information, since of course this is very relevant to what I want to do. I think I am getting the basic consepts involved in it...tomorrow I will continue on what I did today, getting one aspect and trying to start going a bit more in depth.</p>
<p>Yesterday I had asked MCA to suggest me some software programmes I could use to organise my thougths...I had actually asked him for something with cards and stuff, which is what he mainly provided me with, but he also sent me this programme called FreeMind -Mind Map, which I actually found works very well for me, especially to set out the basic thoughts in an ordered way, so when I need to I can just look at them and remember what the basic principles were...so here is a summary of what I have done so far :D</p>
[caption id="" align="aligncenter" width="344" caption="Colour Photographs Mind Map"]<a href="http://farm4.static.flickr.com/3185/2883300696_0388331cf6_b.jpg"><img class="   " title="http://farm4.static.flickr.com/3185/2883300696_0388331cf6_b.jpg" src="http://farm4.static.flickr.com/3185/2883300696_0388331cf6_b.jpg" alt="Colour Photographs Mind Map" width="344" height="137" /></a>[/caption]
<p>This evening one of the girls organised a 'spaghettata' here at the residence...woohooo! I got some spaghetti at last :D. And it was good to at last meet some of the girls and socialise a bit :)</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Get the Dates You Want With Your Own Microsoft Access Dialog Form]]></title>
<link>http://accesstips.wordpress.com/?p=157</link>
<pubDate>Thu, 18 Sep 2008 06:50:52 +0000</pubDate>
<dc:creator>Patrick Wood</dc:creator>
<guid>http://accesstips.ar.wordpress.com/2008/09/18/get-the-dates-you-want-with-your-own-microsoft-access-dialog-form/</guid>
<description><![CDATA[Today you will be able to use your own Date Dialog Form to export your Access Appointments to the Ou]]></description>
<content:encoded><![CDATA[<p><SPAN style="font-size:10pt;font-family:Verdana;">Today you will be able to <B>use your own Date Dialog Form to export your Access Appointments to the Outlook Calendar</B> after you follow the steps in this article. You will also learn one of the most import tasks in programming Access. You will learn how to create and loop through a Recordset, exporting the Appointments within your selected dates to Outlook. But first, let us consider the benefits of using a Custom Dialog Form.<br />
<br>The Date Dialog Form we have been making is a great help to the user. But it is far more than just window dressing. Not only does it make certain tasks easier, the user can get results more quickly, it gives the user more choices and control, and it also helps to avoid errors. The Pop-up Calendar and the Select Dates Combo Box eliminate typing errors that the user might make if the dates had to be typed in. Our code also checks to make sure the selected dates do not cause an error. So there are many benefits to using our Custom Dialog Form. When we are finished with this form (we will have at least two more articles about it) it will be an even more user friendly and powerful tool which you can also use in other Databases.<br />
<br>Here is how our Form appears now.<br />
<br><br />
<IMG src="http://gainingaccess.net/Images/datedialog6.jpg"><br />
<br>All of the controls are in place and named and we just have to finish adding code to make it work. We will go step by step.<br />
<br>As I was going through the code I found that we could save a little bit of coding if we modified our existing code just a little.<br />
<br><strong>1) Find the following Sub:&#160;&#160;Private Sub txtOneDate_GotFocus()<BR>&#160;&#160;&#160;&#160; and change this code:</strong><br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><br />
<TBODY><TR vAlign="top;"><TD style="width:100%;"><FONT face="Courier New"> <br> &#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;' Clear the other textboxes<BR> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Me.txtStartDate = vbNullString<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Me.txtEndDate = vbNullString<br><BR></FONT></TD></TR></TBODY></TABLE><br />
<STRONG>to this:</STRONG><TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><br />
<TBODY><TR vAlign="top;"><TD style="width:100%;"><FONT face="Courier New"><BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Put the Single Date in the other textboxes so<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' we can use them in our SQL "WHERE" Statement<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Me.txtStartDate = Me.txtOneDate<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Me.txtEndDate = Me.txtOneDate<BR><BR></FONT></TD></TR></TBODY></TABLE><br />
So that your sub looks like this:<br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><br />
<TBODY><TR vAlign="top;"><TD style="width:100%;"><FONT face="Courier New"><BR>Private Sub txtOneDate_GotFocus()<BR><BR>&#160;&#160;&#160;&#160;' If txtOneDate has a value<BR>&#160;&#160;&#160;&#160;If Len(Me.txtOneDate &#38; vbNullString) &#62; 0 Then<BR><BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Put the Single Date in the other textboxes<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' so we only have to build one SQL statement<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Me.txtStartDate = Me.txtOneDate<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Me.txtEndDate = Me.txtOneDate<BR><BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'Add the Formatted Date to the DateSelection textbox<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Me.txtDateSelection = "#" &#38; Me.txtOneDate &#38; "#"<BR>&#160;&#160;&#160;&#160;End If<BR>End Sub <BR><BR></FONT></TD></TR></TBODY></TABLE><br />
<br><B>2) Add a Procedure to the "Export By Dates" button's On Click Event.</B><br />
<br>To do that Open the Form in Design view and right-click on the "Export By Dates" button. Select "Properties" at the bottom of the shortcut menu. Click on the "Event" tab. Find the On Click line and click one the ... on the right like this:<br />
<IMG src="http://gainingaccess.net/Images/datedialog7.jpg"><br />
<br>Select "Code Builder" in the Pop-up Window and click OK. The Code Editor should open and you should see the following lines of code:<br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><br />
<TBODY><TR vAlign="top;"><TD style="width:100%;"><FONT face="Courier New"><BR>Private Sub btnExportApptByDates_Click()<BR><BR>End Sub <BR><BR></FONT></TD></TR></TBODY></TABLE><br />
<B>3 ) Declare the Variables to be used in the Procedure</B><br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><br />
<TBODY><TR vAlign="top;"><TD style="width:100%;"><FONT face="Courier New"><BR>&#160;&#160;&#160;&#160;' Declare a variable for the Database<BR>&#160;&#160;&#160;&#160;Dim db As DAO.Database<BR><BR>&#160;&#160;&#160;&#160;' Declare a variable for the Recordset<BR>&#160;&#160;&#160;&#160;Dim rst As DAO.Recordset<BR><BR>&#160;&#160;&#160;&#160;' A variable for Recordset's SQL Statement<BR>&#160;&#160;&#160;&#160;Dim strSQL As String<BR><BR>&#160;&#160;&#160;&#160;' A variable for our "WHERE" statement<BR>&#160;&#160;&#160;&#160;Dim strWhere As String<BR><BR>&#160;&#160;&#160;&#160;' A Variable used to count the number<BR>&#160;&#160;&#160;&#160;' of Appointments added to the Outlook Calendar<BR>&#160;&#160;&#160;&#160;Dim intCount As Integer<BR><BR></FONT></TD></TR></TBODY></TABLE><br />
We are using DAO (Data Access Objects) code instead of ADO (ActiveX Data Objects) code for two reasons. DAO is Access's native language. It is what Access uses to process data. That means DAO is a little faster. Plus it has the added benefit of being a little easier to use because there is less code to write. If you are using Access 2000 or 2002 you may need to set a Reference to the Microsoft DAO 3.6 Library Reference. Other versions have the Reference set by default.<br />
<br>DAO and ADO both have Database and Recordset Objects, but the code for using them is different. If you do not specify DAO or ADO then Access "guesses" at which one you are using and it can cause errors. So always make sure you Declare which one you are using whenever you use a Database or Recordset in code.<br />
<br><B>4 ) Use late binding as before to create an instance of Outlook.</B><br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><br />
<TBODY><TR vAlign="top;"><TD style="width:100%;"><FONT face="Courier New"><BR>&#160;&#160;&#160;&#160;' Use late binding to avoid the "Reference" issue<BR>&#160;&#160;&#160;&#160;Dim objOutlook As Object 'Outlook.Application<BR>&#160;&#160;&#160;&#160;Dim objAppointItem As Object 'olAppointmentItem<BR><BR>&#160;&#160;&#160;&#160;If isAppThere("Outlook.Application") = False Then<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Outlook is not open, create a new instance<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Set objOutlook = CreateObject("Outlook.Application")<BR>&#160;&#160;&#160;&#160;Else<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Outlook is already open--use this method<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Set objOutlook = GetObject(, "Outlook.Application")<BR>&#160;&#160;&#160;&#160;End If<BR><BR></FONT></TD></TR></TBODY></TABLE><br />
<B>5 ) Build the SQL Statement</B><br />
<br>To do this we must use the values selected in the Textboxes as a part of our SQL. We add the dates to the SQL statement by concatenating (Geek Speak for "putting together") the controls (which automatically gets the control's value) with the SQL statement by using the &#38; character.<br />
<br>We must also use the # delimiters for the dates so Access will recognize them as dates. Do not worry if you do not understand all of that now as long as you know that this is needed for the code to work.<br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><TBODY><TR vAlign="top;"><br />
<TD style="width:100%;"><FONT face="Courier New"><BR>&#160;&#160;&#160;&#160;' Start building the SQL "WHERE" Statement<BR>&#160;&#160;&#160;&#160;strWhere = "WHERE ApptDate &#62;= #" &#38; Me.txtStartDate &#38; "#" _<BR>&#160;&#160;&#160;&#160;&#38; " AND ApptDate &#60;= #" &#38; Me.txtEndDate &#38; "#"<BR><BR>&#160;&#160;&#160;&#160;' Finish building the SQL string<BR>&#160;&#160;&#160;&#160;strSQL = "SELECT * FROM tblAppointments " &#38; strWhere &#38; ";"<BR>&#160;&#160;&#160;&#160;'Debug.Print strSQL<BR><BR></FONT></TD></TR></TBODY></TABLE><br />
The <FONT face="Courier New">"WHERE"</FONT> statement filters the data so we only get the records that we want. <FONT face="Courier New">ApptDate</FONT> is the Field in the Table which we see on the Form as Start Date. So our <FONT face="Courier New">"WHERE"</FONT> statement tells us that we only want Start Dates the are Greater Than (&#62;) or Equal To (=) the date contained in our StartDate Textbox. Likewise, we only want End Dates that are Less Than (&#60;) or Equal To (=) the date contained in our EndDate Textbox.<br />
<br>The * is a wildcard character meaning "all". So we are Selecting all records from the Table tblAppointments. We do not want all of the records, just the ones that fall within the dates we select. Our <FONT face="Courier New">"WHERE"</FONT> statement does that for us.<br />
<br>We also enclose our SQL Statement in Quotes because it is a string. However, whenever we use the Control Names in our SQL statement, we must not enclose them in Quotes because in Access Dates are really numbers. Access does not recognize numbers within quotes as numbers, but rather as Strings. When we are finished we have: strSQL = "SELECT * FROM tblAppointments " &#38; strWhere &#38; ";". Now we have it all together so we can open our Recordset.<br />
<br><B>6) Open the Recordset</B><br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><TBODY><TR vAlign="top;"><br />
<TD style="width:100%;"><FONT face="Courier New"><BR>&#160;&#160;&#160;&#160;'Instantiate database<BR>&#160;&#160;&#160;&#160;Set db = CurrentDb()<BR><BR>&#160;&#160;&#160;&#160;' Create Recordset based on strSQL<BR>&#160;&#160;&#160;&#160;' Note: You cannot open a Recordset using SQL<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' with Parameters or criteria if the values<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' of the Parameters are not provided. That is<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' why we built the complete SQL string and used the<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' Text Boxes to supply the values for the criteria.<BR>&#160;&#160;&#160;&#160;' Open the Recordset and use dbOpenDynaset so we can modify records.<BR>&#160;&#160;&#160;&#160;Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)<BR><BR></FONT></TD></TR></TBODY></TABLE><br />
With most Recordsets some type of Loop is used to cycle through each record and get or set the values. There are a number of ways to do this.<br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><TBODY><TR vAlign="top;"><br />
<TD style="width:100%;"><FONT face="Courier New"><BR>&#160;&#160;&#160;&#160;' Move to the first Record in the Recordset<BR> &#160;&#160;&#160;&#160;rst.MoveFirst<BR>&#160;&#160;&#160;&#160;' Begin a Loop and keep looping<BR>&#160;&#160;&#160;&#160;' until the last record is reached.<BR> &#160;&#160;&#160;&#160;Do Until rst.EOF<BR><BR></FONT></TD></TR></TBODY></TABLE><br />
We have instructed Access to keep doing commands until it reached the last record in the recordset.  Think "End of File" when you see <FONT face="Courier New">rst.EOF.</font><br />
<BR><B>7) Add a New Appointment Item with each loop through the Recordset</B><br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><TBODY><TR vAlign="top;"><br />
<TD style="width:100%;"><FONT face="Courier New"><BR><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Create the New Appointment Item each loop through the Recordset<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Set objAppointItem = objOutlook.CreateItem(1) ' olAppointmentItem = 1<BR><BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Add the data to the Appointment Properties<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;With objAppointItem<BR><BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Set the Start Property Value<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' ApptDate is Required by the table no need to check it<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' The Nz Function can handle a Zero Length String or a Null<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Start = Nz(rst!ApptDate) &#38; " " &#38; Nz(rst!ApptTime)<BR><BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Set the End Property Value<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.End = Nz(rst!EndDate) &#38; " " &#38; Nz(rst!EndTime, "")<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Duration = Nz(rst!ApptLength, 0)<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Subject = Nz(rst!Appt)<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Body = Nz(rst!ApptNotes)<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Location = Nz(rst!Location)<BR><BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If rst!ApptReminder = True Then<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If rst!ApptDate &#60; Now() Then<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' No Reminder is needed<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.ReminderOverrideDefault = False<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.ReminderMinutesBeforeStart = 0<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.ReminderSet = False<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Else<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Use the Reminder data<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If Not IsNull(rst!ReminderMinutes) Then<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.ReminderOverrideDefault = True<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.ReminderMinutesBeforeStart = rst!ReminderMinutes<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.ReminderSet = True<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End If<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End If<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End If<BR><BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Add the Category if it exists<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Categories = Nz(rst!Categories)<BR><BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Save the Appointment Item Properties<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Save<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End With<BR><BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Get the number of Appointments added to Outlook<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;intCount = intCount + 1 <BR><BR></FONT></TD></TR></TBODY></TABLE><br />
<B>8 ) Set the AddedToOutlook Field to True for each Appointment added to Outlook</B><br />
<br>We have been using the Recordset to add data to Outlook. Now we will change that and use the same Recordset to add data to the Appointment Table.<br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><TBODY><TR vAlign="top;"><br />
<TD style="width:100%;"><FONT face="Courier New"><BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Set the AddedToOutlook Field to True<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rst.Edit ' We want to edit existing records<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rst!AddedToOutlook = -1 ' True<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rst.Update ' With DAO we must remember to use Update<BR>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;' Move to the Next Record<BR> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rst.MoveNext<BR>&#160;&#160;&#160;&#160;' Here is where you loop back to the <BR>&#160;&#160;&#160;&#160;' beginning of the Recordset<BR>&#160;&#160;&#160;&#160;Loop<BR><BR></FONT></TD></TR></TBODY></TABLE><br />
<B>9 ) Release Memory </B><br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><TBODY><TR vAlign="top;"><br />
<TD style="width:100%;"><FONT face="Courier New"><BR>&#160;&#160;&#160;&#160;' The Loop is finished so release the<BR>&#160;&#160;&#160;&#160;' memory used for the variables.<BR>&#160;&#160;&#160;&#160;Set objAppointItem = Nothing<BR>&#160;&#160;&#160;&#160;Set objOutlook = Nothing<BR>&#160;&#160;&#160;&#160;Set rst = Nothing<BR>&#160;&#160;&#160;&#160;Set db = Nothing<BR><BR></FONT></TD></TR></TBODY></TABLE><br />
<B>10 ) Inform the User </B><br />
<br>If we did not let the user know that the Appointments were added to Outlook then would see no sign that they had been added to Outlook. They would have to open their Outlook Calendar to verify that the Appointments had been added. Since we are trying to save the user time we keep them informed.<br />
<TABLE style="font-size:10pt;background:#e7e7ff;width:100%;"><TBODY><TR vAlign="top;"><br />
<TD style="width:100%;"><FONT face="Courier New"><BR>&#160;&#160;&#160;&#160;' Tell the user how many Appointments were Exported<BR>&#160;&#160;&#160;&#160;MsgBox intCount &#38; " Appointments were added to Outlook.", vbInformation<BR><BR>End Sub <BR><BR></FONT></TD></TR></TBODY></TABLE><br />
We have shown you how to create, open, and use a DAO Recordset to get data from Access and also use the same Recordset to Add data to Access. Recordsets are a popular and powerful feature of Access for which you can find many uses. Now you can use the Dialog Form with other Forms, Reports, and Databases.<br />
<br>Our next article will feature making our Dialog Form more powerful and giving the user more choices. We will build a more complex SQL "WHERE" Statement and use a ListBox to select the exact Appointments we want to Export.<br />
<br>To download the code used in this article visit our <A href="http://gainingaccess.net/GainingAccess/CodeSamples.aspx">Free CodeSamples Page.</A> While you are there, you can download the <a href="http://gainingaccess.net/"><strong>Free Access Pop-up Calendar</strong></a>--the easiest calendar I have ever used.  It has no "Reference" problems because it is an Access Form.<br />
<br>To download the full Appointment Database become a Premium Member with <A href="http://gainingaccess.net/Membership/GetTotalAccess.aspx">Total Access.</A> </p>
<p>Happy computing,<br />
Patrick (Pat) Wood<br />
<a href="http://gainingaccess.net">Gaining Access</a><br />
<a href="http://www.churchmanagesoftware.com">Church Management Software Solutions</a></p>
<p></span></p>
<p><a href="http://technorati.com/faves?sub=addfavbtn&#38;add=http://advenet.com/hunter57/blog/default.aspx"><img src="http://static.technorati.com/pix/fave/tech-fav-1.png" alt="Add to Technorati Favorites" /></a><br />
</SPAN></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Drawing in Excel 6 - getting shape properties]]></title>
<link>http://newtonexcelbach.wordpress.com/?p=357</link>
<pubDate>Wed, 17 Sep 2008 01:50:20 +0000</pubDate>
<dc:creator>dougaj4</dc:creator>
<guid>http://newtonexcelbach.ar.wordpress.com/2008/09/17/drawing-in-excel-6-getting-shape-properties/</guid>
<description><![CDATA[Previous post
One of the less than useful new &#8220;features&#8221; of Excel 2007 is that its macro]]></description>
<content:encoded><![CDATA[<p><a href="http://newtonexcelbach.wordpress.com/2008/07/26/drawing-in-excel-5-shape-list/">Previous post</a></p>
<p>One of the less than useful new "features" of Excel 2007 is that its macro recorder no longer records operations on shapes, which removes the easiest way to discover the exact names of shape properties, and how to manipulate them.  The file <a title="Right click to download" href="http://interactiveds.com.au/software/ShapeProps.zip">ShapeProps.zip </a>contains a spreadheet with a User Defined Function (UDF) that will return a list of property names, and the values for each property, for any named shape.  In addition it will generate VBA code to read aditional properties if the correct property names are inserted in a list on the spreadsheet.</p>
<p> </p>
<p>The UDF currently reads 94 different properties, which can either be returned as a column array of all 94 values, or if a list of property numbers is entered only the listed property values will be returned.  See the screen shot below for examples.</p>
[caption id="attachment_358" align="aligncenter" width="468" caption="ShapeProp() Output"]<a href="http://newtonexcelbach.files.wordpress.com/2008/09/shapeprop1.jpg"><img class="size-large wp-image-358" title="shapeprop1" src="http://newtonexcelbach.wordpress.com/files/2008/09/shapeprop1.jpg?w=468" alt="ShapeProp() Output" width="468" height="239" /></a>[/caption]<br />
[caption id="attachment_359" align="aligncenter" width="468" caption="ShapeProp() code generation sheet"]<a href="http://newtonexcelbach.wordpress.com/files/2008/09/shapeprop2.jpg"><img src="http://newtonexcelbach.wordpress.com/files/2008/09/shapeprop2.jpg?w=468" alt="ShapeProp() code generation sheet" title="shapeprop2" width="468" height="230" class="size-large wp-image-359" /></a>[/caption]
]]></content:encoded>
</item>
<item>
<title><![CDATA[Writing Chemical Equations in Excel: The Easy Way (no ions)]]></title>
<link>http://experibiz.wordpress.com/?p=17</link>
<pubDate>Mon, 15 Sep 2008 06:21:28 +0000</pubDate>
<dc:creator>experibiz</dc:creator>
<guid>http://experibiz.ar.wordpress.com/2008/09/15/writing-chemical-equations-in-excel-the-easy-way-no-ions/</guid>
<description><![CDATA[I find it very tedious to write a chemical formulas and equations because of the subscripts, so I de]]></description>
<content:encoded><![CDATA[<p>I find it very tedious to write a chemical formulas and equations because of the subscripts, so I decided to create a VBA code in Excel which handles just that. It worked fine, until I realized that it won't have any benefit since I've done it in Excel, and lesson plans and the likes are almost always done in Word.</p>
<p>Well, recently, I showed this to my colleague and he suggested pasting the transformed equation from Excel to Word with the hope that the right format will be preserved. Guess what, it worked. That's why I'm sharing it now.</p>
<p>My code however, won't work with equations that involve ions, and fractional coefficients but I'm already working on it. Hopefully, I can post another set of code in the future which could be used for both ionic and non-ionic chemical formula.</p>
<p>Here is an example of a chemical equation that can be formatted automatically. Just take note that the spaces between the compounds, + and -&#62; are required to be formatted properly.</p>
<p>CH4 + 2O2 -&#62; CO2 + 2H2O</p>
<p>Here are the steps (MS Excel 2003).</p>
<ol>
<li>Open a blank worksheet.</li>
<li>If the Visual Basic Toolbar is not visible do the following: View -&#62;Toolbars-&#62;Visual Basic</li>
<li>On the Visual Basic Toolbar, click on Visual Basic Editor</li>
<li>On the Menubar of Visual Basic, click Insert -&#62;Module</li>
<li>Copy the code below and paste inside the module.</li>
<p>Sub write_chem()</p>
<p>For Each rng In Selection<br />
mystring = rng.Value<br />
Length = Len(mystring)<br />
For i = 1 To Length<br />
char = Mid(mystring, i, 1)<br />
If i &#60;&#62; 1 Then<br />
charfound = found(Mid(mystring, i - 1, 1))<br />
Else<br />
charfound = True<br />
End If</p>
<p>On Error Resume Next<br />
x = Int(char)<br />
If Err &#60;&#62; 13 And charfound = False Then<br />
rng.Characters(i, 1).Font.Subscript = True<br />
Else<br />
rng.Font.Subscript = False<br />
End If<br />
Next i<br />
Next rng</p>
<p>End Sub</p>
<p>Function found(char As String) As Boolean<br />
Dim mylist As Variant</p>
<p>mylist = Array(&#34; + &#34; , &#34; . &#34; , &#34; - &#34;, Space(1))</p>
<p>For i = 0 To 4<br />
If mylist(i) = char Then<br />
found = True<br />
Exit For<br />
Else<br />
found = False<br />
End If<br />
Next i<br />
End Function</p>
<li>Close the Visual Basic Editor</li>
<li>On the Visual Basic Toolbar, click Control Toolbox -&#62; Command button</li>
<li>Draw a command button on the worksheet</li>
<li>Double-click the command button to open again the Visual Basic Editor.</li>
<li>Within the Private Sub and End Sub, type write_chem. Your code should look something like the one below</li>
<p>Private Sub CommandButton1_Click()<br />
write_chem<br />
End Sub</p>
<li>Close the Visual Basic Editor</li>
<li>On the Visual Basic Toolbar, click Exit Design Mode</li>
<li>Type  Chemical Equations or formula in Excel.</li>
<li>Select the cell/s and click the command button to format it correctly. Try H2SO4 and 2CCl4 as examples</li>
<li>For the 2CCl4, notice that the number 4 became a subscript while the number 2 was preserved.</li>
<li>You can now paste the formatted equations or formula in MS Word.</li>
<li>When you are using this code, write all the chemical formulas/equations first in Excel then format everything before you paste them to Word.</li>
</ol>
<p>I'll be working on the code for the superscripts next time. For now, please enjoy.</p>
<p>By the way and as always, please feel free to comment. And if you need the worksheet please give me your email address so I can send it to you. Cheers!!!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Referring to Rows &amp; Columns]]></title>
<link>http://excelling.wordpress.com/?p=36</link>
<pubDate>Sun, 14 Sep 2008 21:53:15 +0000</pubDate>
<dc:creator>parkercpa</dc:creator>
<guid>http://excelling.ar.wordpress.com/2008/09/14/referring-to-rows-columns/</guid>
<description><![CDATA[In the previous post I spoke about referring to cells and ranges of cells, but in the instance you n]]></description>
<content:encoded><![CDATA[<p>In the previous post I spoke about referring to cells and ranges of cells, but in the instance you need to refer to an entire row or an entire column you can do so with what was learned previously, but it would be rather cumbersome. Visual Basic has a way for us to so simply. The format is just like what we used when referring to a range, but instead of the word Range we'll use the word Rows or Columns. A couple of examples are:</p>
<p>[sourcecode language='vb']<br />
Rows(1)  'refers to row 1<br />
Columns(1)  'refers to column 1 or you can use...<br />
Columns("A")  'again refers to the 1st column and has to have the quotes<br />
Columns  'no numbers or letters refers to ALL columns on the worksheet<br />
[/sourcecode]</p>
<p>You can also select multiple rows or columns by separating with commas like the following examples:</p>
<p>[sourcecode language='vb']<br />
Rows("1:1,3:3")  'refers to multiple non-contiguous rows, i.e. row 1 AND row 3<br />
Rows("1:3")  'refers to multiple contiguous rows, i.e. rows 1 THROUGH 3<br />
[/sourcecode]</p>
<p>In my next post I'll show you a shortcut notation for referring to cells.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Referring to Cells and Ranges of Cells]]></title>
<link>http://excelling.wordpress.com/?p=32</link>
<pubDate>Sat, 13 Sep 2008 14:06:58 +0000</pubDate>
<dc:creator>parkercpa</dc:creator>
<guid>http://excelling.ar.wordpress.com/2008/09/13/referring-to-cells-and-ranges-of-cells/</guid>
<description><![CDATA[Now that you&#8217;ve got a workbook open, it is very likely that one of the first  things you]]></description>
<content:encoded><![CDATA[<p>Now that you've got a workbook open, it is very likely that one of the first  things you'll need to do is to refer to a cell or a range of cells in order to  put data there or to manipulate the data that is already there. It takes one  simple line of code to do so and the format is as follows: Range("<em>cell  range</em>"). Following is a number of variations to select a number of  different ranges.</p>
<p>[sourcecode language='vb']<br />
Range("A1")  'select cell A1<br />
Range("A1:B2")   'select cells from A1 through B2<br />
Range("A1:B2,A3:B3")  'select a non-contiguous range of cells<br />
Range("A:A")  'select column A<br />
Range("1:1")   'select row 1[/sourcecode]</p>
<p>The hardest part for me to remember is  the quotation marks. It is very similar to using a 'sum' formula in the way you  present the cells in the parenthesis...just remember the quotes. This is the  most common way you will see a range of cells or a single cell referred to when  looking at VBA code. This is called the A1 notation obviously because it refers  to cells using the letter (for the column) and number (for the  row).</p>
<p>Sometimes it makes sense to refer to cells in a different way  using index numbers. What that means is using numbers to refer to both the  column and the row.  The confusing part for me is that the notation gets  reversed from what you are used to when using the A1 notation. A1 notation  starts with the letter, i.e. the column, and then the number, i.e. the row.  Using the index number reverses that, referring to the row first and then the  column. Other than only seeing numbers to clue you in that the index numbers are  being used as opposed to A1 notation, the word 'range' is also not used. Instead  the word 'cell' is used.</p>
<p>The reason for this type of notation is that it  is useful when using a counter or other method, such as looping to increment the  cell location you are referring to. Below is an example used in Excel's help  file to show the use of the Index  Notation:</p>
<p>[sourcecode language='vb']<br />
Worksheets("Sheet1").Cells(6,1).Value = 10[/sourcecode]</p>
<p>This line of  code tells Excel to find the cell that is in the 6th row and 1st column (Cell A6  using A1 notation)on Sheet1 and make its value equal to 10. Excel's help file  goes on to show an example of how this would be used if it were looped by  showing the following code:</p>
<p>[sourcecode language='vb']<br />
Sub CycleThrough()<br />
    Dim Counter As Integer<br />
    For Counter = 1 To 20<br />
        Worksheets("Sheet1").Cells(Counter, 3).Value = Counter<br />
    Next Counter<br />
End Sub[/sourcecode]</p>
<p>If you were going through the help file this would  show you a number of things that would be completely new to you that wouldn't  make any sense but I think it is simple enough that you could get the jist of  how it would be used.  Since I've put the code out there I will explain the  steps that this code is running through in English.</p>
<p><strong>Sub  CycleThrough()</strong> is the opening of the VBA code. All code starts with the  word Sub and then the name of the macro followed with the open and closed  partenthesis.</p>
<p><strong>Dim Counter As Integer.</strong> This tells Excel  to create a variable called Counter and make that variable an integer.</p>
<p><strong>For Counter = 1 To 20</strong>. This starts a For Next loop and  tells Excel that for every time you go through this loop find the variable named  Counter and assign it the value of 1 until you get to the 'Next' line. Then use  the value of 2, then 3, then 4 and so on until 20 is reached.</p>
<p><strong>Worksheets("Sheet1").Cells(Counter, 3).Value =  Counter</strong>.  This is where the value of the Counter plays its part. The  first time through the loop Excel has assigned the value of 1 to the variable  Counter.  In essence you can invision this line of code rewritten with the  number 1 in the place of the word Counter.  The first time through this loop  Excel will find the cell that is in the first row down and third column over  (this would be cell C1) on Sheet1 and make it value equal to 1, which is the  value currently being held for the variable Counter. The next time the loop runs  through it will move to cell C2, the 2nd row down and 3rd column over, and make  its value equal to 2.</p>
<p><strong>Next Counter</strong>. This moves the code  back up to the For Counter line and increments the number up by one.</p>
<p><strong>End Sub</strong>. This ends the code.</p>
<p>That gets off the  topic a bit, but it does show how and why you would use this variation of  notation to refer to a cell.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[How to Get a Date--Build a Microsoft Access Date Dialog Form]]></title>
<link>http://accesstips.wordpress.com/?p=141</link>
<pubDate>Thu, 11 Sep 2008 05:03:12 +0000</pubDate>
<dc:creator>Patrick Wood</dc:creator>
<guid>http://accesstips.ar.wordpress.com/2008/09/11/how-to-get-a-date-build-a-microsoft-access-date-dialog-form/</guid>
<description><![CDATA[In our last Article we showed you how to export custom data from a Form to an Outlook Appointment in]]></description>
<content:encoded><![CDATA[<div><span style="font-size:10pt;font-family:Verdana;">In our last Article we showed you how to <strong>export custom data from a Form to an Outlook Appointment in the Outlook Calendar</strong>.  But what if we want to save time and export several appointments to the Outlook Calendar?  If we just used a Recordset and exported them all, there would be duplicate Appointments.  We may not need to send last Month’s Appointments to Outlook.  It would be very nice to be able to select the Appointments we want to put in Outlook.  But how can we do that?</span></div>
<p> <span style="font-size:10pt;font-family:Verdana;"><strong>We will show you how you can create a Custom Dialog Form to select exactly the Appointments you want to put in your Outlook Calendar.</strong>   When the series is finished you will have 3 different methods to drill down to just the data you want.</span></p>
<p> <span style="font-size:10pt;font-family:Verdana;">If you have never created a dialog form, you are reading the right article.  We will take it step by step so you can do this again when you need a dialog form to handle other data.  First, we will show you how to make it easy for the user to select Appointments by selecting a single date or a range of dates.  Second, we will show you how to filter a specific field so you do not see categories of Appointments you do not want. Then we will show you how to use a Multi-select ListBox to pick each Appointment you want. <strong> We will show you how to make a Dialog Form to filter your data by dates.</strong>  This is something that you can use many times as you use and develop Access Databases.</span></p>
<div><span style="font-size:10pt;font-family:Verdana;"><strong>First, create a <em>new</em> Form that is Unbound</strong>—it will not have a Record Source.  On that Form place an unbound textbox at least a couple of inches long and leave about an inch above it.  Move the label and place in on top (but not covering) of the textbox.  Change the label to read: "Dates Selected".  We want to center it so it is in the middle of the textbox.  An easy way to do this is to stretch the label until it is the same length as the textbox.  Then click on the center align button and you have something like this:</span></div>
<div></div>
<p><span style="font-size:10pt;font-family:Verdana;"></p>
<p style="text-align:center;"> <br />
<img src="http://gainingaccess.net/Images/datedialog1.jpg" alt="" /></p>
<p> Next, add an unbound combo box, and put "Select Dates:" in the label.  Name the combo box "<span style="font-family:Courier New;"> cboDateRanges</span>".  In the combo box’s property sheet, click the Data tab, change the Row Source Type to Value List and paste the following into the Row Source line:</p>
<p style="font-family:Courier New;">All;Today;Yesterday;Last Sunday;This Month;This Quarter;This Year;Last Month;Last Quarter;Last Year;Month to Date;Quarter to Date;Year to Date;Last 12 Months;January ;February ;March ; April ;May ;June ;July ;August ;September ;<br />
October ;November ;December</p>
<p style="text-align:center;"><img src="http://gainingaccess.net/Images/datedialog2.jpg" alt="" /></p>
<p> Then set the <span style="font-family:Courier New;">Limit To List</span> Property to "Yes".  Later we will add some code to this combobox’s <span style="font-family:Courier New;">AfterUpdate Event</span> that will get all of these date selections for us.</p>
<p>Now add three unbound textboxes and change their labels to match this image:</p>
<p style="text-align:center;"><img src="http://gainingaccess.net/Images/datedialog3.jpg" alt="" /></p>
<p>Leave a little extra space above and below the Single Date textbox.</p>
<p>Next we need to add 3 Calendar buttons to our form which open the Pop-up Calendar when clicked.  We can use the little Calendar images by themselves or add the image to a command button.   You can copy the image from here and use it yourself if you like. <img src="http://gainingaccess.net/Images/btnCalMain2.bmp" alt="" />  We will need to place the Calendar Buttons like this:</p>
<p style="text-align:center;"><img src="http://gainingaccess.net/Images/datedialog4.jpg" alt="" /></p>
<p>And above the first textbox we need to add a command button.  After you put the button on the form the Wizard opens up.  Click the "Cancel" button.  Name the button "btnExportApptByDates" and change the caption to "Export By Dates".</p>
<p style="text-align:center;"><img src="http://gainingaccess.net/Images/datedialog5.jpg" alt="" /></p>
<p>After changing the Form’s Caption to "Export Appointments to Outlook" and adding some labels with solid backgrounds and some lines and rectangles it makes our Form more pleasing to the eye and easier to use.  Now we can begin adding code.</p>
<p>Open the "Dates Selected" textbox’s Properties Sheet. Click the other tab and name the textbox <span style="font-family:Courier New;">txtDateSelection</span>.  We will display the dates selected there. </p>
<p>Name the "One Date" textbox <span style="font-family:Courier New;">txtOneDate</span> and the image or button beside it <span style="font-family:Courier New;">btnOneDate</span>.   Name the "Start Date" textbox <span style="font-family:Courier New;">txtStartDate</span> and the image or button beside it <span style="font-family:Courier New;">btnStartDate</span> and name the "End Date" textbox <span style="font-family:Courier New;">txtEndDate</span> and the button <span style="font-family:Courier New;">btnEndDate</span>. </p>
<p>For the Calendar Buttons we will first get a global variable to add the date to the textbox control—in this case the <span style="font-family:Courier New;">txtOneDate</span> textbox. </p>
<table style="font-size:10pt;background:#e7e7ff;width:100%;" border="0">
<tbody>
<tr valign="top;">
<td style="width:100%;"><span style="font-family:Courier New;"><br />
Set ctlIn = Me.Controls("txtOneDate")<br />
DoCmd.OpenForm "frmCalendar" ' Launch calendar form     </p>
<p></span></td>
</tr>
</tbody>
</table>
<p>The first line of code sets the variable and the second line of code opens the <strong>Pop-up Calendar Form</strong>.  The Calendar is actually an Access Form so you do not have to worry about versions, broken References, and dll files.  You can find the link to my site to download the free Calendar along with the code and Module at the end of this article.</p>
<p>If we have previously left dates in the other textboxes we want to clear them.  So the procedure will look like this:</p>
<table style="font-size:10pt;background:#e7e7ff;width:100%;" border="0">
<tbody>
<tr valign="top;">
<td style="width:100%;"><span style="font-family:Courier New;"><br />
Private Sub btnOneDate_Click()<br />
    ' Use a Global Variable to get the selected date<br />
    Set ctlIn = Me.Controls("txtOneDate")<br />
    DoCmd.OpenForm "frmCalendar" ' Launch calendar form</p>
<p>    ' Clear the other textboxes<br />
    Me.txtStartDate = vbNullString<br />
    Me.txtEndDate = vbNullString<br />
End Sub</p>
<p></span></td>
</tr>
</tbody>
</table>
<p>We are using vbNullString instead of "" because vbNullString does not use as much memory and it makes it clear exactly what we are doing.</p>
<p>You can set the code for the other two Calendar buttons similarly.</p>
<table style="font-size:10pt;background:#e7e7ff;width:100%;" border="0">
<tbody>
<tr valign="top;">
<td style="width:100%;"><span style="font-family:Courier New;"><br />
Private Sub btnStartDate_Click()<br />
    ' Use a Global Variable to get the selected date<br />
    Set ctlIn = Me.Controls("txtStartDate")<br />
    DoCmd.OpenForm "frmCalendar" ' Launch calendar form</p>
<p>    ' Clear txtOneDate<br />
    Me.txtOneDate = vbNullString<br />
End Sub</p>
<p>Private Sub btnEndDate_Click()<br />
    ' Use a Global Variable to get the selected date<br />
    Set ctlIn = Me.Controls("txtEndDate")<br />
   DoCmd.OpenForm "frmCalendar" ' Launch calendar form</p>
<p>    ' Clear txtOneDate<br />
    Me.txtOneDate = vbNullString<br />
End Sub</p>
<p></span></td>
</tr>
</tbody>
</table>
<p>After the Calendar adds the date to the textbox, it sets the focus on it also.  This gives us an opportunity to do some necessary work with code.  The most important things we need to do is format the date for use in a query and add it to the Date Selected textbox.</p>
<table style="font-size:10pt;background:#e7e7ff;width:100%;" border="0">
<tbody>
<tr valign="top;">
<td style="width:100%;"><span style="font-family:Courier New;"><br />
Private Sub txtOneDate_GotFocus()<br />
    ' If txtOneDate has a value<br />
    If Len(Me.txtOneDate &#38; vbNullString) &#62; 0 Then</p>
<p>        ' Clear the other textboxes<br />
        Me.txtStartDate = vbNullString<br />
        Me.txtEndDate = vbNullString</p>
<p>        'Add the Formatted Date to the DateSelection textbox<br />
        Me.txtDateSelection = "#" &#38; Me.txtOneDate &#38; "#"<br />
    End If<br />
End Sub</p>
<p></span></td>
</tr>
</tbody>
</table>
<p>Dates in Access require the # "delimiters".  This tells Access that the value between the # characters are dates or time values. </p>
<p>After dates are added to the Start Date or the End Date, there is a little more work to do before we can use the dates.  <strong>We want to be sure that the Start Date is not <em>later</em> than the End Date</strong>.  The <span style="font-family:Courier New;">CDate Function</span> converts the textbox's String to a <span style="font-family:Courier New;">DateTime</span> DataType so we can make sure that the Dates will work correctly.  If we did not convert the string into a date, we would be geting the <em>alphabetical</em> String order instead of the <em>numeric</em> Date order. </p>
<table style="font-size:10pt;background:#e7e7ff;width:100%;" border="0">
<tbody>
<tr valign="top;">
<td style="width:100%;"><span style="font-family:Courier New;"><span style="font-family:Courier New;"><br />
Private Sub txtStartDate_GotFocus()<br />
    ' Declare variables to use hold the formatted dates<br />
    Dim strStartDate As String<br />
    Dim strEndDate As String </p>
<p>   ' Check to see that there is an End Date<br />
    If Len(Me.txtEndDate &#38; vbNullString) &#62; 0 Then</p>
<p>        ' Make sure the Start Date is not later than the End Date<br />
        If CDate(Me.txtEndDate) &#62; CDate(Me.txtStartDate) Then</p>
<p>            ' Format the dates and pass the value to the variables<br />
            strStartDate = "#" &#38; Me.txtStartDate &#38; "#"<br />
            strEndDate = "#" &#38; Me.txtEndDate &#38; "#"</p>
<p>            ' Store the dates in the Hidden Form for later use<br />
            Forms!frmDataHoldPAW!htxtStartDate = strStartDate<br />
            Forms!frmDataHoldPAW!htxtEndDate = strEndDate</p>
<p>            ' Display the date range in the Date Selection textbox<br />
            Me.txtDateSelection = "BETWEEN #" &#38; Me.txtStartDate _<br />
              &#38; "# AND #" &#38; Me.txtEndDate &#38; "#"</p>
<p>        End If<br />
    End If<br />
End Sub</p>
<p></span></span></td>
</tr>
</tbody>
</table>
<p>Almost identical code is used after the End Date is added to the textbox.</p>
<table style="font-size:10pt;background:#e7e7ff;width:100%;" border="0">
<tbody>
<tr valign="top;">
<td style="width:100%;"><span style="font-family:Courier New;"><br />
Private Sub txtEndDate_GotFocus()<br />
    ' Declare variables to use to hold the formatted dates<br />
    Dim strStartDate As String<br />
    Dim strEndDate As String</p>
<p>    ' Check to see that there is an Start Date<br />
    If Len(Me.txtStartDate &#38; vbNullString) &#62; 0 Then</p>
<p>        ' Make sure the Start Date is not later than the End Date<br />
        If CDate(Me.txtEndDate) &#62; CDate(Me.txtStartDate) Then</p>
<p>            ' Format the dates and pass the value to the variables<br />
            strStartDate = "#" &#38; Me.txtStartDate &#38; "#"<br />
            strEndDate = "#" &#38; Me.txtEndDate &#38; "#"</p>
<p>            ' Store the dates in the Hidden Form for later use<br />
            Forms!frmDataHoldPAW!htxtStartDate = strStartDate<br />
            Forms!frmDataHoldPAW!htxtEndDate = strEndDate</p>
<p>            ' Display the date range in the Date Selection textbox<br />
            Me.txtDateSelection = "BETWEEN #" &#38; Me.txtStartDate &#38; "# AND #" &#38; Me.txtEndDate &#38; "#"<br />
        End If<br />
    End If<br />
End Sub</p>
<p></span></td>
</tr>
</tbody>
</table>
<p>I saved the best code for last.  When you make a selection in the Select Dates combobox it adds the right dates to either the One Date textbox or the Start Date and End Date textboxes.  We named the combobox <span style="font-family:Courier New;">cboDateRanges</span>.  It uses a very helpful bit of code that you may need to use many times.  We use the combobox's <span style="font-family:Courier New;">AfterUpdate Event</span> to get the right dates in the right places.</p>
<table style="font-size:10pt;background:#e7e7ff;width:100%;" border="0">
<tbody>
<tr valign="top;">
<td style="width:100%;"><span style="font-family:Courier New;"><br />
Private Sub cboDateRanges_AfterUpdate()<br />
    Select Case cboDateRanges<br />
        Case "All"<br />
            Me.txtStartDate = #1/1/1900#<br />
            Me.txtEndDate = #12/31/2050#<br />
            Me.txtOneDate = Null<br />
        Case "Today"<br />
            Me.txtStartDate = Null<br />
            Me.txtEndDate = Null<br />
            Me.txtOneDate = Date<br />
            Me.txtStartDate = Me.txtOneDate<br />
            Me.txtEndDate = Me.txtOneDate<br />
        Case "Yesterday"<br />
            Me.txtStartDate = Null<br />
            Me.txtEndDate = Null<br />
            Me.txtOneDate = Date - 1<br />
            Me.txtStartDate = Me.txtOneDate<br />
            Me.txtEndDate = Me.txtOneDate<br />
        Case "Last Sunday"<br />
            Me.txtStartDate = Null<br />
            Me.txtEndDate = Null<br />
            Me.txtOneDate = Date - Weekday(Date) + 1<br />
            Me.txtStartDate = Me.txtOneDate<br />
            Me.txtEndDate = Me.txtOneDate<br />
        Case "This Month"<br />
            Me.txtStartDate = DateSerial(Year(Date), Month(Date), 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), Month(Date) + 1, 0)<br />
            Me.txtOneDate = Null<br />
        Case "This Quarter"<br />
            Me.txtStartDate = DateSerial(Year(Date), Int((Month(Date) - 1) / 3) * 3 + 1, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), Int((Month(Date) - 1) / 3) * 3 + 4, 0)<br />
            Me.txtOneDate = Null<br />
        Case "This Year"<br />
            Me.txtStartDate = DateSerial(Year(Date), 1, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 12, 31)<br />
            Me.txtOneDate = Null<br />
        Case "Last Month"<br />
            Me.txtStartDate = DateSerial(Year(Date), Month(Date) - 1, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), Month(Date), 0)<br />
            Me.txtOneDate = Null<br />
        Case "Last Quarter"<br />
            Me.txtStartDate = DateSerial(Year(Date), Int((Month(Date) - 1) / 3) * 3 + 1 - 3, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), Int((Month(Date) - 1) / 3) * 3 + 4 - 3, 0)<br />
            Me.txtOneDate = Null<br />
        Case "Last Year"<br />
            Me.txtStartDate = DateSerial(Year(Date) - 1, 1, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date) - 1, 12, 31)<br />
            Me.txtOneDate = Null<br />
        Case "Month to Date"<br />
            Me.txtStartDate = DateSerial(Year(Date), Month(Date), 1)<br />
            Me.txtEndDate = Date<br />
            Me.txtOneDate = Null<br />
        Case "Quarter to Date"<br />
            Me.txtStartDate = DateSerial(Year(Date), Int((Month(Date) - 1) / 3) * 3 + 1, 1)<br />
            Me.txtEndDate = Date<br />
            Me.txtOneDate = Null<br />
        Case "Year to Date"<br />
            Me.txtStartDate = DateSerial(Year(Date), 1, 1)<br />
            Me.txtEndDate = Date<br />
            Me.txtOneDate = Null<br />
        Case "Last 12 Months"<br />
            Me.txtStartDate = DateSerial(Year(Date) - 1, Month(Date), Day(Date) + 1)<br />
            Me.txtEndDate = Date<br />
            Me.txtOneDate = Null<br />
        Case "January"<br />
            Me.txtStartDate = DateSerial(Year(Date), 1, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 2, 1 - 1)<br />
            Me.txtOneDate = Null<br />
        Case "February"<br />
            Me.txtStartDate = DateSerial(Year(Date), 2, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 3, 1 - 1)<br />
            Me.txtOneDate = Null<br />
        Case "March"<br />
            Me.txtStartDate = DateSerial(Year(Date), 3, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 4, 1 - 1)<br />
            Me.txtOneDate = Null<br />
        Case "April"<br />
            Me.txtStartDate = DateSerial(Year(Date), 4, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 5, 1 - 1)<br />
            Me.txtOneDate = Null         Case "May"<br />
            Me.txtStartDate = DateSerial(Year(Date), 5, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 6, 1 - 1)<br />
            Me.txtOneDate = Null<br />
        Case "June"<br />
            Me.txtStartDate = DateSerial(Year(Date), 6, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 7, 1 - 1)<br />
        Case "July"<br />
            Me.txtStartDate = DateSerial(Year(Date), 7, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 8, 1 - 1)<br />
            Me.txtOneDate = Null<br />
        Case "August"<br />
            Me.txtStartDate = DateSerial(Year(Date), 8, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 9, 1 - 1)<br />
            Me.txtOneDate = Null<br />
        Case "September"<br />
            Me.txtStartDate = DateSerial(Year(Date), 9, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 10, 1 - 1)<br />
            Me.txtOneDate = Null<br />
        Case "October"<br />
            Me.txtStartDate = DateSerial(Year(Date), 10, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 11, 1 - 1)<br />
            Me.txtOneDate = Null<br />
        Case "November"<br />
            Me.txtStartDate = DateSerial(Year(Date), 11, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 12, 1 - 1)<br />
            Me.txtOneDate = Null<br />
        Case "December"<br />
            Me.txtStartDate = DateSerial(Year(Date), 12, 1)<br />
            Me.txtEndDate = DateSerial(Year(Date), 13, 1 - 1)<br />
            Me.txtOneDate = Null<br />
    End Select</p>
<p>    If IsNull(Me.txtOneDate) Then<br />
        ' Put the date range in the Date Selection textbox<br />
        Me.txtDateSelection = "BETWEEN #" &#38; Me.txtStartDate &#38; "# AND #" &#38; Me.txtEndDate &#38; "#"<br />
    Else<br />
        Me.txtDateSelection = "#" &#38; Me.txtOneDate &#38; "#"<br />
    End IfEnd Sub   </p>
<p></span></td>
</tr>
</tbody>
</table>
<p>You may wonder how the code can get the last day of a certain month or the date of last Sunday for example.  Actually it is not very hard at all.  The code gets the first day of the next Month and subtracts one day to get the last day of the Previous Month.  It works similarly to get last Sunday or any day of the week.  For more information about the code look up <span style="font-family:Courier New;">DateSerial</span> in Access VBA Help.</p>
<p>The <strong>Dialog Form</strong> is almost ready to use with Date Selection.  In our next article in this series we will show you how to <strong>build a SQL "Where" string</strong> and how to <strong>loop through a Recordset</strong> to add Appointments from the selected Date Range to the Outlook Calendar.</p>
<p>You can download the <a href="http://gainingaccess.net/"><span style="color:#800080;">Free Pop-up Calendar</span></a> used in this article from our <a href="http://gainingaccess.net/">Gaining Access</a> website's Free Downloads Page.</p>
<p>Premium Members get <a href="http://gainingaccess.net/Membership/GetTotalAccess.aspx">Total Access</a> to download the databases used in the articles as well as other free downloads. </p>
<p>Happy computing,<br />
Patrick (Pat) Wood<br />
<a href="http://gainingaccess.net">Gaining Access</a><br />
<a href="http://www.churchmanagesoftware.com">Church Management Software Solutions</a></p>
<p><a href="http://technorati.com/faves?sub=addfavbtn&#38;add=http://advenet.com/hunter57/blog/default.aspx"><img src="http://static.technorati.com/pix/fave/tech-fav-1.png" alt="Add to Technorati Favorites" /></a><br />
</span></p>
]]></content:encoded>
</item>

</channel>
</rss>
