<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3268512826072972755</id><updated>2011-07-07T21:46:08.769-07:00</updated><title type='text'>Microsoft Access Code Warrior</title><subtitle type='html'>Tips, code and thoughts on Microsoft Access</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-5312510031077927348</id><published>2010-07-13T12:31:00.001-07:00</published><updated>2010-07-19T08:29:16.201-07:00</updated><title type='text'>Part 3: Why I grew to love Microsoft Access Data Projects</title><content type='html'>&lt;b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Why I learned to love Microsoft Access Data Projects&lt;/b&gt;&lt;br /&gt;As a seasoned Access programmer, it seams all I do lately is Access with SQL Server, in part because of the great combination of SQL Server Express with Access and the zero cost of using Express for my clients. For the greater part of my career I've been using regular MDB's for all of my work, but that all changed with a recent project of mine's.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Why I had to use a Microsoft Access Data Project&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;My client, a nationally recognized home cleaning firm with franchisees across the USA, needed to consolidate each franchisee's data into one national database for reporting of income. Up until then each franchisee was using a local MDB and mailing in there numbers, going national would avoid the hassle and provide real time intelligence to corporate headquarters on the health of the business. I decided on Microsoft Access 2007 runtime with SQL Server Express 2008 R2, but I rant into the following issues with a regular MDB:&lt;br /&gt;&lt;br /&gt;•Record Locking: Test users were getting the dreaded message "Another user has modified the data..." when running data modification routines in code. Mind you this was after I had optimized the code to use one connection throughout the project.&lt;br /&gt;&lt;br /&gt;•Speed: The regular Access MDB can open up multiple connections to the SQL Server backend, users were noticing a significant delay in downloading data off the Internet.&lt;br /&gt;&lt;br /&gt;Both issues were resolved when I switched to using an ADP for the frontend. Not only did the record locking issue disappear, the speed of the application was better when SQL Server on the web then with a local Access file! &lt;br /&gt;&lt;br /&gt;Microsoft Data Projects work well...if you avoid certain pitfalls&lt;br /&gt;&lt;br /&gt;&lt;b&gt;I've written a series of articles on the following issues with ADP:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;•DoCmd.OpenForm where and filter clauses will not work.&lt;br /&gt;&lt;br /&gt;•It's not easy to supply your own login form when using SQL Server security.&lt;br /&gt;&lt;br /&gt;•You're going to have to learn SQL Server tools in order to maximize your Access user experience&lt;br /&gt;&lt;br /&gt;I encourage you to learn how to use ADPs and gain from their unique relationship with SQL Server, and I hope you too will learn to love them!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-5312510031077927348?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/5312510031077927348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/part-3-why-i-grew-to-love-microsoft.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/5312510031077927348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/5312510031077927348'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/part-3-why-i-grew-to-love-microsoft.html' title='Part 3: Why I grew to love Microsoft Access Data Projects'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-5735522332926998990</id><published>2010-07-13T12:30:00.001-07:00</published><updated>2010-07-19T08:15:26.939-07:00</updated><title type='text'>Launch Email Window from Form</title><content type='html'>If your database contains an email field, you can easily modify your form so that users can single click to create an email in their default email program.&lt;br /&gt;&lt;br /&gt;First, modify the control's Display as Hyperlink property to Always, second, modify the control's on click event with the following code:&lt;br /&gt;&lt;br /&gt;If Not IsNull(Me.EMail) Then &lt;br /&gt;&lt;br /&gt;Application.FollowHyperlink "mailto:" &amp;amp; Me.EMail&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Note: Change EMail to the name of your email control on your form&lt;br /&gt;&lt;br /&gt;That's it! Users will see the familiar web hand when they hover over the email address, and when they click access will launch a new email window for them to further edit before sending off.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-5735522332926998990?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/5735522332926998990/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/launch-email-window-from-form.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/5735522332926998990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/5735522332926998990'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/launch-email-window-from-form.html' title='Launch Email Window from Form'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-153806922740997370</id><published>2010-07-13T12:29:00.001-07:00</published><updated>2010-07-19T08:17:19.544-07:00</updated><title type='text'>Part 2 Access ADP Tip : Get rid of the login box on startup</title><content type='html'>Note: This is part two of a series of articles on Access Data Projects, to see the complete list and other articles please click here.&lt;br /&gt;&lt;br /&gt;Access ADPs can provide you with the flexibility and power only a direct connection to SQL Server can provide, but a major drawback to a developer is the login box that will always show up when you distribute your application, Access will stubbornly hold on to the last account used to connect with the server, unless you store the password with the file, and that may not be ideal.&lt;br /&gt;&lt;br /&gt;Use a low level SQL Server account and reset the project connection&lt;br /&gt;&lt;br /&gt;I came across a partial solution to the problem using this support article. It describes how you can reset the connection to the user and password of your choosing, but it does not address how to get rid of the login box on startup.&lt;br /&gt;&lt;br /&gt;The solution I developed is twofold: Use a low level account on startup, show a custom login form and then reset the project connection.&lt;br /&gt;&lt;br /&gt;Start out by creating a new SQL Server login, (or a new Windows login if your ADP is on a Windows network and your using Windows authentication on your SQL Server database), that only has rights to the login stored procedure you've created for your ADP. (If you don't have a login stored procedure you can find one soon in the same section where all are articles are located). This will allow you to save the username and password with your ADP project, but not provide rights to any table, view or stored procedure if the account info is compromised. Whatever you do, never use a high level account and password as your startup account with the ADP.&lt;br /&gt;&lt;br /&gt;Now that you've saved the low level login and password with the ADP, the dreaded login form will no longer display on startup, allowing you to instead display your own login form for the users of your application. Have them enter their login name and password, have them click on a button labeled Login and then proceed to break the connection and restore it with their connections to SQL Server.&lt;br /&gt;&lt;br /&gt;Here is the sample code to validate their login, use it on your login form:&lt;br /&gt;&lt;br /&gt;If Not ChangeADPConnection(Me.txtUserID, Me.txtPassword) Then&lt;br /&gt;&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;txtUserID and txtPassword are two fields on the form where users enter their user name and password, substitute them with your own control names if you wish.&lt;br /&gt;&lt;br /&gt;The ChangeADPConnection procedure will use the user name and password from the login form to validate the user and establish a connection with the server using their rights and not the rights of the low level login:&lt;br /&gt;&lt;br /&gt;Public Function ChangeADPConnection(strUN As String, strPW As String) As Boolean&lt;br /&gt;&lt;br /&gt;Dim strConnect As String&lt;br /&gt;Dim strServerName As String&lt;br /&gt;Dim strDBName As String&lt;br /&gt;&lt;br /&gt;strServerName = "YourServerIPAddress" &lt;br /&gt;&lt;br /&gt;strDBName = "YourDatabase"&lt;br /&gt;&lt;br /&gt;On Error GoTo EH:&lt;br /&gt;&lt;br /&gt;Application.CurrentProject.CloseConnection&lt;br /&gt;&lt;br /&gt;'The Provider, Data Source, and Initial Catalog arguments are required.&lt;br /&gt;&lt;br /&gt;strConnect = "Provider=SQLOLEDB.1" &amp;amp; _&lt;br /&gt;&lt;br /&gt;";Data Source=" &amp;amp; strServerName &amp;amp; _&lt;br /&gt;&lt;br /&gt;";Initial Catalog=" &amp;amp; strDBName&lt;br /&gt;&lt;br /&gt;If strUN &amp;lt;&amp;gt; "" Then&lt;br /&gt;&lt;br /&gt;strConnect = strConnect &amp;amp; ";user id=" &amp;amp; strUN&lt;br /&gt;&lt;br /&gt;If strPW &amp;lt;&amp;gt; "" Then&lt;br /&gt;&lt;br /&gt;strConnect = strConnect &amp;amp; ";password=" &amp;amp; strPW&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Else 'Try to use integrated security if no username is supplied.&lt;br /&gt;&lt;br /&gt;strConnect = strConnect &amp;amp; ";integrated security=SSPI"&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Application.CurrentProject.OpenConnection strConnect&lt;br /&gt;&lt;br /&gt;ChangeADPConnection = True&lt;br /&gt;&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;EH:&lt;br /&gt;&lt;br /&gt;MsgBox Err.Number &amp;amp; ": " &amp;amp; Err.Description, vbCritical, "Connection Error"&lt;br /&gt;&lt;br /&gt;ChangeADPConnection = False&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Access ADPs have a unique advantage over regular MDB's when using SQL Server, I encourage you to use them if you can, along with SQL Server stored procedures, and create great solutions for your clients.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-153806922740997370?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/153806922740997370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/part-2-access-adp-tip-get-rid-of-login.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/153806922740997370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/153806922740997370'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/part-2-access-adp-tip-get-rid-of-login.html' title='Part 2 Access ADP Tip : Get rid of the login box on startup'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-2603116341111454142</id><published>2010-07-13T12:28:00.003-07:00</published><updated>2010-07-19T08:22:34.470-07:00</updated><title type='text'>Part 1 Access ADP Tip: Using ADP ServerFilter property</title><content type='html'>Note: This is part one of a series of articles on Access ADP projects, to see the complete list and other articles please click here.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Where and Filter Clause do not work when using DoCmd.OpenForm Statement&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;One of the issues you will find when working with an Access Data Project, (ADP), is the lack of functionality in the Where and Filter clause of the DoCmd.OpenForm statement, they don't work with ADPs. There are two techniques you can use to overcome this limitation:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Set The Form's Record Source Property&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;On startup or during the course of using the form, you can set the form's record source property using the OpenArgs argument:&lt;br /&gt;&lt;br /&gt;Me.RecordSource = "Select * from MyTable Where " &amp;amp; Me.OpenArgs&lt;br /&gt;&lt;br /&gt;Use ServerFilter Property&lt;br /&gt;&lt;br /&gt;Another method is to use the ServerFilter property of the form. On the open event you will need to use the following statements&lt;br /&gt;&lt;br /&gt;Me.ServerFilter = ""&lt;br /&gt;&lt;br /&gt;Me.ServerFilter = Me.OpenArgs&lt;br /&gt;&lt;br /&gt;The first line is needed to reset the property before you set it to something else.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-2603116341111454142?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/2603116341111454142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/part-1-access-adp-tip-using-adp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/2603116341111454142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/2603116341111454142'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/part-1-access-adp-tip-using-adp.html' title='Part 1 Access ADP Tip: Using ADP ServerFilter property'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-7700806116750269767</id><published>2010-07-13T12:28:00.001-07:00</published><updated>2010-07-19T08:27:14.515-07:00</updated><title type='text'>How to create PDFs in Word using Access VBA</title><content type='html'>Office 2007 will allow you to easily create PDFs from any Word Document using the output menu on the Office button, (Access does too with Reports), but recently I had to create a procedure for a client that wanted to convert Word docs to PDF, email them and do it all from Access.&lt;br /&gt;&lt;br /&gt;Note: To make this code work, you will need to add a reference to Word 2007 to your Access database. &lt;br /&gt;&lt;br /&gt;Here is the code:&lt;br /&gt;&lt;br /&gt;Private Sub CreatePDF(strSourceFile As String, strDestFile As String)&lt;br /&gt;&lt;br /&gt;Dim objWord As Word.Application&lt;br /&gt;&lt;br /&gt;Dim objWordDoc As Word.Document&lt;br /&gt;&lt;br /&gt;On Error GoTo ErrorHandler&lt;br /&gt;&lt;br /&gt;Set objWord = CreateObject("Word.Application")&lt;br /&gt;&lt;br /&gt;objWord.Visible = True&lt;br /&gt;&lt;br /&gt;Set objWordDoc = objWord.Documents.Open(strSourceFile)&lt;br /&gt;&lt;br /&gt;If Not objWord Is Nothing Then&lt;br /&gt;&lt;br /&gt;objWordDoc.ExportAsFixedFormat strDestFile, wdExportFormatPDF, False, wdExportOptimizeForPrint, wdExportAllDocument&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;ExitProcedure:&lt;br /&gt;&lt;br /&gt;objWordDoc.Close False&lt;br /&gt;&lt;br /&gt;objWord.Quit&lt;br /&gt;&lt;br /&gt;Set objWordDoc = Nothing&lt;br /&gt;&lt;br /&gt;Set objWord = Nothing&lt;br /&gt;&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;ErrorHandler:&lt;br /&gt;&lt;br /&gt;MsgBox Err.Description, vbInformation, "Error Creating PDF"&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Note how I display Word at the begining of the process, not doing so may leave Word "hanging" in memory if your code comes back with an error.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-7700806116750269767?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/7700806116750269767/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/how-to-create-pdfs-in-word-using-access.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/7700806116750269767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/7700806116750269767'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/how-to-create-pdfs-in-word-using-access.html' title='How to create PDFs in Word using Access VBA'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-7363748864744533903</id><published>2010-07-13T12:27:00.001-07:00</published><updated>2010-07-19T08:24:56.835-07:00</updated><title type='text'>Using a SQL Server stored procedure with a insert query in Access</title><content type='html'>If you're using a SQL Server database with an Access frontend, than this article is for you. Leverging the power of Stored Procedures from Access has numerous benefits: your server can perform transactions that would take far longer in Access. Recently I came accross the following issue when working on a client's database.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Stored Procedures with Action Queries can be a problem&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I created a stored procedure that does multiple updates using action queries, and I wanted the results of the procedure returned back to Access so that the user can now how many records were updated. I wanted the results inserted into a local Access table for a historical reference, and I had decided on using a pass-through query with another insert query in Access to accomplish the task. The insert query would kick off the pass-through query that would in turn kick off the stored procedure on the server.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Pass-Through Query + Insert: A dangerous combo!&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I used this Microsoft article to create the pass through query in my code. (If your stored procedure does not take arguments then you don't have to this, rather, just create the pass-throgh query once with dummy code, then do your insert query, then finalyze your pass-through). Then I tried using the QBE window in Access, but in doing so the system wanted to execute my pass-through query to get the column names from my stored procedure. Not good, since it would kick-off my action queries on the server and cause havoc to my data! Instead I wrote my insert insert query using SQL view in Access, when I went to save the query it still wanted to execute my pass-through, but I had not saved the connection string, so there was no harm done.&lt;br /&gt;&lt;br /&gt;Summary Steps&lt;br /&gt;&lt;br /&gt;* Create a dummy pass-through query in Access that will NOT execute the stored procedure, don't bother with a connection string at this point.&lt;br /&gt;&lt;br /&gt;* Create an insert query using the SQL mode in access, not the Query by Example grid.&lt;br /&gt;&lt;br /&gt;* Modify your code to create the pass-through query on the fly if needed. (You will need to do so if your stored procedure requires parameters)&lt;br /&gt;&lt;br /&gt;* Kick off the whole process in your code by first creating the pass-through and then executing the insert query:&lt;br /&gt;&lt;br /&gt;CreateSPT "qrySQLCompleteImport", "Exec sp_CompleteImport " &amp;amp; Me.txtFranchiseID, strSQL&lt;br /&gt;&lt;br /&gt;DoCmd.SetWarnings False&lt;br /&gt;&lt;br /&gt;DoCmd.OpenQuery "qryCompleteImport"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-7363748864744533903?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/7363748864744533903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/using-sql-server-stored-procedure-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/7363748864744533903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/7363748864744533903'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/using-sql-server-stored-procedure-with.html' title='Using a SQL Server stored procedure with a insert query in Access'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-5929582629605653480</id><published>2010-07-13T12:25:00.001-07:00</published><updated>2010-07-19T08:26:29.058-07:00</updated><title type='text'>Using SQL Server Views with Access: Index needed for editing data.</title><content type='html'>SQL Server views are one of the best tools a Microsoft Access programmer can use to limit exposure to data and improve Access performance.&lt;br /&gt;&lt;br /&gt;Unfortunately, you can't modify data in a view unless it has a unique index, read on if that is the case for you. (You can create indexed views in SQL Server, this article applies to non-indexed views)&lt;br /&gt;&lt;br /&gt;After you have linked your view to your Access application, create a new query or execute the following SQL statement in your code to create the index:&lt;br /&gt;&lt;br /&gt;Create Index ix_name On view_name(fields) With Primary&lt;br /&gt;&lt;br /&gt;ix_name: The name you assign to your primary index.&lt;br /&gt;&lt;br /&gt;view_name: The name of your view in Access.&lt;br /&gt;&lt;br /&gt;fields: One or more fields seperated by commas that will compose your primary key.&lt;br /&gt;&lt;br /&gt;That's all there is to it. We hope you can "Discover the Power of Your Data!" with this tip.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-5929582629605653480?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/5929582629605653480/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/using-sql-server-views-with-access.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/5929582629605653480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/5929582629605653480'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/using-sql-server-views-with-access.html' title='Using SQL Server Views with Access: Index needed for editing data.'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-1215884610836490530</id><published>2010-07-13T12:24:00.001-07:00</published><updated>2010-07-19T08:36:28.128-07:00</updated><title type='text'>SQL Server: Easily Grant Select to All Tables and/or Views in a Database</title><content type='html'>(Note: I loved the code I found on the original posting, but it would not work without a simple change. I'm copying the post here and highlighting my changes, talk about a time saver!)&lt;br /&gt;&lt;br /&gt;Granting Select to all tables for a login can be an extremely painful and lengthy process. Utilizing the SQL Server Management Studio to perform this means going table by table and checking the Select checkbox for each individual table, this makes a real nightmare if you are working with hundreds of tables. You can do this in mere seconds versus hours by using the Query window. Here’s how:&lt;br /&gt;&lt;br /&gt;1. Open SQL Server Management Studio. &lt;br /&gt;&lt;br /&gt;2. Connect to the desired Server.&lt;br /&gt;&lt;br /&gt;3. Click the New Query button.&lt;br /&gt;&lt;br /&gt;4. Select the desired database from the dropdown in the toolbar.&lt;br /&gt;&lt;br /&gt;5. To grant Select to all tables in the database, copy and paste the following into your Query window:&lt;br /&gt;&lt;br /&gt;DECLARE @login varchar(50)&lt;br /&gt;&lt;br /&gt;SET @login = 'loginname'&lt;br /&gt;&lt;br /&gt;DECLARE @ROWID Int --Added by Juan Soto&lt;br /&gt;&lt;br /&gt;DECLARE @SQLSTR VARCHAR(Max) --Added by Juan Soto&lt;br /&gt;&lt;br /&gt;DECLARE @tables TABLE(ROWID int IDENTITY(1,1), SQLSTR varchar(500))&lt;br /&gt;&lt;br /&gt;INSERT INTO @tables&lt;br /&gt;&lt;br /&gt;SELECT 'GRANT SELECT ON ' + NAME + ' TO '+@login&lt;br /&gt;&lt;br /&gt;FROM sysobjects&lt;br /&gt;&lt;br /&gt;WHERE TYPE = 'U'&lt;br /&gt;&lt;br /&gt;AND NAME NOT LIKE 'SYNC%'&lt;br /&gt;&lt;br /&gt;DECLARE @rowid int, @sqlstr varchar(500)&lt;br /&gt;&lt;br /&gt;SET @rowid = 0&lt;br /&gt;&lt;br /&gt;SET @sqlstr = ''&lt;br /&gt;&lt;br /&gt;DECLARE grant_tbl_cursor CURSOR FOR&lt;br /&gt;&lt;br /&gt;SELECT ROWID, SQLSTR&lt;br /&gt;&lt;br /&gt;FROM @tables&lt;br /&gt;&lt;br /&gt;ORDER BY ROWID&lt;br /&gt;&lt;br /&gt;OPEN grant_tbl_cursor&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM grant_tbl_cursor&lt;br /&gt;&lt;br /&gt;INTO @rowid,@sqlstr&lt;br /&gt;&lt;br /&gt;WHILE @@FETCH_STATUS = 0&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;EXECUTE (@sqlstr)&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM grant_tbl_cursor&lt;br /&gt;&lt;br /&gt;INTO @rowid,@sqlstr&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;CLOSE grant_tbl_cursor&lt;br /&gt;&lt;br /&gt;DEALLOCATE grant_tbl_cursor&lt;br /&gt;&lt;br /&gt;6. In the second line of the pasted query, change loginname to the login that you wish to grant Select to all tables.&lt;br /&gt;&lt;br /&gt;7. Execute the query.&lt;br /&gt;&lt;br /&gt;To grant Select to all Views in the database, follow the above steps but use the following:&lt;br /&gt;&lt;br /&gt;DECLARE @login varchar(50)&lt;br /&gt;&lt;br /&gt;SET @login = 'loginname'&lt;br /&gt;&lt;br /&gt;DECLARE @ROWID Int --Added by Juan Soto&lt;br /&gt;&lt;br /&gt;DECLARE @SQLSTR VARCHAR(Max) --Added by Juan Soto&lt;br /&gt;&lt;br /&gt;DECLARE @views TABLE(ROWID int IDENTITY(1,1), SQLSTR varchar(500))&lt;br /&gt;&lt;br /&gt;INSERT INTO @views&lt;br /&gt;&lt;br /&gt;SELECT 'GRANT SELECT ON ' + NAME + ' TO '+@login&lt;br /&gt;&lt;br /&gt;FROM sysobjects&lt;br /&gt;&lt;br /&gt;WHERE TYPE = 'V'&lt;br /&gt;&lt;br /&gt;SET @rowid = 0&lt;br /&gt;&lt;br /&gt;SET @sqlstr = ''&lt;br /&gt;&lt;br /&gt;DECLARE grant_vw_cursor CURSOR FOR&lt;br /&gt;&lt;br /&gt;SELECT ROWID, SQLSTR&lt;br /&gt;&lt;br /&gt;FROM @views&lt;br /&gt;&lt;br /&gt;ORDER BY ROWID&lt;br /&gt;&lt;br /&gt;OPEN grant_vw_cursor&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM grant_vw_cursor&lt;br /&gt;&lt;br /&gt;INTO @rowid,@sqlstr&lt;br /&gt;&lt;br /&gt;WHILE @@FETCH_STATUS = 0&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;EXECUTE (@sqlstr)&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM grant_vw_cursor&lt;br /&gt;&lt;br /&gt;INTO @rowid,@sqlstr&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;CLOSE grant_vw_cursor&lt;br /&gt;&lt;br /&gt;DEALLOCATE grant_vw_cursor&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-1215884610836490530?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/1215884610836490530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/sql-server-easily-grant-select-to-all.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/1215884610836490530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/1215884610836490530'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/sql-server-easily-grant-select-to-all.html' title='SQL Server: Easily Grant Select to All Tables and/or Views in a Database'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-4843718622472349249</id><published>2010-07-13T12:23:00.003-07:00</published><updated>2010-07-19T08:37:18.640-07:00</updated><title type='text'>Stuck on how to connect to a data source?</title><content type='html'>The other day I needed to connect to my local instance of SQL Server Express 2008, and I wanted to do it without exposing my SQL Server via TCP/IP, (why invite the world to my doorstep if the server is for local use only?). I was having trouble doing so until I found the right syntax at ConnectionStrings.com:&lt;br /&gt;&lt;br /&gt;Data Source=.\SQLExpress;Integrated Security=true; AttachDbFilename=&lt;br /&gt;DataDirectory&lt;br /&gt;\mydb.mdf;User Instance=true;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The key for me was using ".\SQLExpress" in my connection string.&lt;/b&gt; &lt;br /&gt;&lt;br /&gt;The site has a wide range of connection strings for pratically any data source in the planet, head on over and bookmark it, you may never know when it may come in handy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-4843718622472349249?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/4843718622472349249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/stuck-on-how-to-connect-to-data-source.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/4843718622472349249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/4843718622472349249'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/stuck-on-how-to-connect-to-data-source.html' title='Stuck on how to connect to a data source?'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-2929294389608615403</id><published>2010-07-13T12:23:00.001-07:00</published><updated>2010-07-19T08:42:54.154-07:00</updated><title type='text'>Create DELETE Audit Tables in SQL Server</title><content type='html'>This is a modification to an earlier tip I wrote, whereas this code will only record delete changes, my earlier article will record delete and update changes to the data.&lt;br /&gt;&lt;br /&gt;I found code online by Brett Kaiser and I modified it for my purposes, with a mind to other Access developers I made some changes which I will explain here. Note: This article assumes you're familiar with SQL Server tools and TSQL.&lt;br /&gt;&lt;br /&gt;To view the original post from Brett Kaiser, please click here:&lt;br /&gt;&lt;br /&gt;Using SQL Server Management Studio express, open a new query window pointing towards your DB and start by creating a new table that will store all of the tables you wish to implement audit triggers for:&lt;br /&gt;&lt;br /&gt;-- CREATE A Driver Table for all Tables in your catalog you wish to audit&lt;br /&gt;&lt;br /&gt;CREATE TABLE tblAudit(TABLE_CATALOG sysname, TABLE_SCHEMA sysname, TABLE_NAME sysname)&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;-- Now replace the code above with the code below in the query window. You can either type the table names into the new tblAudit table or you can use the following code which will insert a record for each table in the database. CAUTION: Don't add triggers to a table unless they are mission critical, some tables you may not want to add triggers for our look up tables or tables where not everyone has access too. If you do use the code below to populate the tblAudit table then STOP and review the list of tables and delete any unncessary tables you don't wish to track.&lt;br /&gt;&lt;br /&gt;INSERT INTO tblAudit(TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME)&lt;br /&gt;&lt;br /&gt;SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME &lt;br /&gt;&lt;br /&gt;FROM INFORMATION_SCHEMA.Tables&lt;br /&gt;&lt;br /&gt;WHERE TABLE_NAME LIKE 'tbl%'&lt;br /&gt;&lt;br /&gt;-- NOTE: Review the list of tables before going to the next step below&lt;br /&gt;&lt;br /&gt;-- Now you're ready to create the audit tables with the code below:&lt;br /&gt;&lt;br /&gt;DECLARE myCursor99 CURSOR&lt;br /&gt;&lt;br /&gt;FOR&lt;br /&gt;&lt;br /&gt;SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME&lt;br /&gt;&lt;br /&gt;FROM tblAudit&lt;br /&gt;&lt;br /&gt;DECLARE @TABLE_CATALOG sysname, @TABLE_SCHEMA sysname, @TABLE_NAME sysname, @COLUMN_NAMES varchar(MAX), @sql varchar(MAX)&lt;br /&gt;&lt;br /&gt;SELECT @COLUMN_NAMES = ''&lt;br /&gt;&lt;br /&gt;OPEN myCursor99&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM myCursor99 INTO @TABLE_CATALOG, @TABLE_SCHEMA, @TABLE_NAME&lt;br /&gt;&lt;br /&gt;WHILE @@FETCH_STATUS = 0&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;SELECT @SQL = 'CREATE TABLE ' + @TABLE_CATALOG + '.' + @TABLE_SCHEMA + '.' + @TABLE_NAME + '_H ('&lt;br /&gt;&lt;br /&gt;+ ' HIST_ADD_DT datetime DEFAULT (getDate()), HIST_ADD_TYPE char(1) NOT NULL' &lt;br /&gt;&lt;br /&gt;+ ', HIST_ADD_SYSTEM_USER sysname NOT NULL, HIST_ADD_USER_NAME sysname NOT NULL'&lt;br /&gt;&lt;br /&gt;+ ', HIST_ADD_HOSTNAME sysname NOT NULL, HIST_ADD_SPID int NOT NULL, HIST_ADD_DESC varchar(50) '&lt;br /&gt;&lt;br /&gt;, @COLUMN_NAMES = @COLUMN_NAMES + ', ' + COLUMN_NAME&lt;br /&gt;&lt;br /&gt;+ ' ' + DATA_TYPE&lt;br /&gt;&lt;br /&gt;+ CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL THEN '(' + CONVERT(varchar(20),CHARACTER_MAXIMUM_LENGTH) + ')'&lt;br /&gt;&lt;br /&gt;WHEN DATA_TYPE = 'decimal' THEN '(' + CONVERT(varchar(20),NUMERIC_PRECISION) + ',' &lt;br /&gt;&lt;br /&gt;+ CONVERT(varchar(20),NUMERIC_SCALE) + ')'&lt;br /&gt;&lt;br /&gt;ELSE ''&lt;br /&gt;&lt;br /&gt;END &lt;br /&gt;&lt;br /&gt;FROM INFORMATION_SCHEMA.Columns&lt;br /&gt;&lt;br /&gt;WHERE TABLE_CATALOG = @TABLE_CATALOG AND TABLE_SCHEMA = @TABLE_SCHEMA AND TABLE_NAME = @TABLE_NAME&lt;br /&gt;&lt;br /&gt;ORDER BY ORDINAL_POSITION&lt;br /&gt;&lt;br /&gt;SELECT @SQL = @SQL + @COLUMN_NAMES + ')'&lt;br /&gt;&lt;br /&gt;SELECT @sql = REPLACE(@SQL, '-1', 'MAX')&lt;br /&gt;&lt;br /&gt;SELECT @sql = REPLACE(@SQL, ', Default ', ', [Default] ')&lt;br /&gt;&lt;br /&gt;SELECT SQL = @sql&lt;br /&gt;&lt;br /&gt;EXEC(@SQL)&lt;br /&gt;&lt;br /&gt;SELECT @SQL = '', @COLUMN_NAMES = ''&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM myCursor99 INTO @TABLE_CATALOG, @TABLE_SCHEMA, @TABLE_NAME&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;CLOSE myCursor99&lt;br /&gt;&lt;br /&gt;DEALLOCATE myCursor99&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;-- The code below was added by me and not part of the original article, in order for users to be able to see changes to the data, they are going to need security rights to the audit tables: Insert and Select. The following code will cycle through all of the tables in the database that end in '_h' and assign the rights to the Public group. (All users)&lt;br /&gt;&lt;br /&gt;DECLARE&lt;br /&gt;&lt;br /&gt;myCursor99 CURSOR&lt;br /&gt;&lt;br /&gt;FOR&lt;br /&gt;&lt;br /&gt;SELECT&lt;br /&gt;&lt;br /&gt;TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME&lt;br /&gt;&lt;br /&gt;FROM tblAudit&lt;br /&gt;&lt;br /&gt;DECLARE @TABLE_CATALOG sysname, @TABLE_SCHEMA sysname, @TABLE_NAME sysname, @COLUMN_NAMES varchar(MAX), @sql varchar(MAX)&lt;br /&gt;&lt;br /&gt;SELECT @COLUMN_NAMES = ''&lt;br /&gt;&lt;br /&gt;OPEN&lt;br /&gt;&lt;br /&gt;myCursor99&lt;br /&gt;&lt;br /&gt;FETCH&lt;br /&gt;&lt;br /&gt;NEXT FROM myCursor99 INTO @TABLE_CATALOG, @TABLE_SCHEMA,@TABLE_NAME&lt;br /&gt;&lt;br /&gt;WHILE @@FETCH_STATUS = 0&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;SELECT @SQL = 'GRANT SELECT ON ' + @TABLE_CATALOG + '.' +@TABLE_SCHEMA + '.' + @TABLE_NAME + '_H TO PUBLIC'&lt;br /&gt;&lt;br /&gt;SELECT SQL = @sql&lt;br /&gt;&lt;br /&gt;EXEC(@SQL)&lt;br /&gt;&lt;br /&gt;SELECT @SQL = 'GRANT INSERT ON ' + @TABLE_CATALOG + '.' + @TABLE_SCHEMA+ '.' + @TABLE_NAME + '_H TO PUBLIC'&lt;br /&gt;&lt;br /&gt;EXEC(@SQL)&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM myCursor99 INTO @TABLE_CATALOG,@TABLE_SCHEMA, @TABLE_NAME&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;CLOSE myCursor99&lt;br /&gt;&lt;br /&gt;DEALLOCATE myCursor99&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;-- Now Lets create the audit TRIGGERS. Note: I've modified the original code so that it will not record changes to the Timestamp field and code that will encapsulate the word DEFAULT correctly when it's encountered in the table. I also don't wish to save the domain name along with the username in the table, so I've added code for that as well.&lt;br /&gt;&lt;br /&gt;DECLARE myCursor99 CURSOR&lt;br /&gt;&lt;br /&gt;FOR&lt;br /&gt;&lt;br /&gt;SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM tblAudit&lt;br /&gt;&lt;br /&gt;DECLARE @TABLE_CATALOG sysname, @TABLE_SCHEMA sysname, @TABLE_NAME sysname, @COLUMN_NAMES varchar(8000), @sql varchar(8000)&lt;br /&gt;&lt;br /&gt;SELECT @COLUMN_NAMES = ''&lt;br /&gt;&lt;br /&gt;OPEN myCursor99&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM myCursor99 INTO @TABLE_CATALOG, @TABLE_SCHEMA, @TABLE_NAME&lt;br /&gt;&lt;br /&gt;WHILE @@FETCH_STATUS = 0&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;SELECT @COLUMN_NAMES = @COLUMN_NAMES + ', ' + COLUMN_NAME&lt;br /&gt;&lt;br /&gt;FROM INFORMATION_SCHEMA.Columns&lt;br /&gt;&lt;br /&gt;WHERE TABLE_CATALOG = @TABLE_CATALOG AND TABLE_SCHEMA = @TABLE_SCHEMA AND TABLE_NAME = @TABLE_NAME And DATA_TYPE &amp;lt;&amp;gt; 'timestamp'&lt;br /&gt;&lt;br /&gt;ORDER BY ORDINAL_POSITION&lt;br /&gt;&lt;br /&gt;SELECT @SQL = 'CREATE TRIGGER ' + @TABLE_SCHEMA + '_' + @TABLE_NAME + '_TR ON ' + @TABLE_SCHEMA + '.' +@TABLE_NAME&lt;br /&gt;&lt;br /&gt;+ ' FOR DELETE AS '&lt;br /&gt;&lt;br /&gt;+ ' DECLARE @HOSTNAME sysname, @DESC varchar(50) '&lt;br /&gt;&lt;br /&gt;+ ' SELECT @HOSTNAME = hostname from master.dbo.sysprocesses where spid = @@SPID '&lt;br /&gt;&lt;br /&gt;+ ' IF EXISTS(SELECT * FROM ' + @TABLE_NAME + ') SELECT @DESC = '&lt;br /&gt;&lt;br /&gt;+ '''' + '''' + ' ELSE SELECT @DESC = ' + '''' + 'MASS DELETE' + ''''&lt;br /&gt;&lt;br /&gt;+ ' If Not Exists (Select * From Inserted) And Exists (Select * From Deleted) And @DESC = '''' '&lt;br /&gt;&lt;br /&gt;+ ' INSERT INTO ' + @TABLE_NAME + '_H ( '&lt;br /&gt;&lt;br /&gt;+ ' HIST_ADD_TYPE, HIST_ADD_SYSTEM_USER, HIST_ADD_USER_NAME, HIST_ADD_HOSTNAME, HIST_ADD_SPID, HIST_ADD_DESC'&lt;br /&gt;&lt;br /&gt;+ @COLUMN_NAMES + ')'&lt;br /&gt;&lt;br /&gt;+ ' SELECT ''D'', SYSTEM_USER, REPLACE (USER_NAME(),''DOMAINNAME\'','''') , @HOSTNAME, @@SPID, @DESC'&lt;br /&gt;&lt;br /&gt;+ @COLUMN_NAMES + ' FROM deleted'&lt;br /&gt;&lt;br /&gt;+ ' If Not Exists (Select * From Inserted) And Exists (Select * From Deleted) And @DESC &amp;lt;&amp;gt; '''' '&lt;br /&gt;&lt;br /&gt;+ ' INSERT INTO ' + @TABLE_NAME + '_H ( '&lt;br /&gt;&lt;br /&gt;+ ' HIST_ADD_TYPE, HIST_ADD_SYSTEM_USER, HIST_ADD_USER_NAME, HIST_ADD_HOSTNAME, HIST_ADD_SPID, HIST_ADD_DESC'&lt;br /&gt;&lt;br /&gt;+ @COLUMN_NAMES + ')'&lt;br /&gt;&lt;br /&gt;+ ' SELECT TOP 1 ''D'', SYSTEM_USER, REPLACE(USER_NAME(),''DOMAINNAME\'',''''), @HOSTNAME, @@SPID, @DESC'&lt;br /&gt;&lt;br /&gt;+ @COLUMN_NAMES + ' FROM deleted'&lt;br /&gt;&lt;br /&gt;SELECT @sql = REPLACE(@SQL, ', Default ', ', [Default] ')&lt;br /&gt;&lt;br /&gt;SELECT @sql = REPLACE(@SQL, ', Default) ', ', [Default]) ')&lt;br /&gt;&lt;br /&gt;Print @SQL&lt;br /&gt;&lt;br /&gt;Select TRIGGERSQL = @sql&lt;br /&gt;&lt;br /&gt;EXEC(@SQL)&lt;br /&gt;&lt;br /&gt;SELECT @SQL = '', @COLUMN_NAMES = ''&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM myCursor99 INTO @TABLE_CATALOG, @TABLE_SCHEMA, @TABLE_NAME&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;CLOSE myCursor99&lt;br /&gt;&lt;br /&gt;DEALLOCATE myCursor99&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;-- Ok, you're done! But what if you make a mistake? You can easily get rid of ALL triggers created earlier by running the following TSQL and starting the process anew&lt;br /&gt;&lt;br /&gt;-- *********** DROP TRIGGER CODE FOLLOWS ************&lt;br /&gt;&lt;br /&gt;-- Use this code in case you need to drop any triggers created earlier, in case&lt;br /&gt;&lt;br /&gt;DECLARE myCursor99 CURSOR&lt;br /&gt;&lt;br /&gt;FOR&lt;br /&gt;&lt;br /&gt;SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME&lt;br /&gt;&lt;br /&gt;FROM tblAudit&lt;br /&gt;&lt;br /&gt;DECLARE @TABLE_CATALOG sysname, @TABLE_SCHEMA sysname, @TABLE_NAME sysname, @COLUMN_NAMES varchar(8000), @sql varchar(8000)&lt;br /&gt;&lt;br /&gt;SELECT @COLUMN_NAMES = ''&lt;br /&gt;&lt;br /&gt;OPEN myCursor99&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM myCursor99 INTO @TABLE_CATALOG, @TABLE_SCHEMA, @TABLE_NAME&lt;br /&gt;&lt;br /&gt;WHILE @@FETCH_STATUS = 0&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;SELECT @COLUMN_NAMES = @COLUMN_NAMES + ', ' + COLUMN_NAME&lt;br /&gt;&lt;br /&gt;FROM INFORMATION_SCHEMA.Columns&lt;br /&gt;&lt;br /&gt;WHERE TABLE_CATALOG = @TABLE_CATALOG AND TABLE_SCHEMA = @TABLE_SCHEMA AND TABLE_NAME = @TABLE_NAME&lt;br /&gt;&lt;br /&gt;ORDER BY ORDINAL_POSITION&lt;br /&gt;&lt;br /&gt;--Select @SQL = 'DROP ' + @TABLE_SCHEMA + '_' + @TABLE_NAME + '_TR ON ' + @TABLE_SCHEMA + '.' +@TABLE_NAME&lt;br /&gt;&lt;br /&gt;Select @SQL = 'DROP TRIGGER ' + @TABLE_SCHEMA + '_' + @TABLE_NAME + '_TR'&lt;br /&gt;&lt;br /&gt;Select SQL = @SQL&lt;br /&gt;&lt;br /&gt;EXEC(@SQL)&lt;br /&gt;&lt;br /&gt;SELECT @SQL = ''&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM myCursor99 INTO @TABLE_CATALOG, @TABLE_SCHEMA, @TABLE_NAME&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;CLOSE myCursor99&lt;br /&gt;&lt;br /&gt;DEALLOCATE myCursor99&lt;br /&gt;&lt;br /&gt;GO&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-2929294389608615403?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/2929294389608615403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/create-delete-audit-tables-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/2929294389608615403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/2929294389608615403'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/create-delete-audit-tables-in-sql.html' title='Create DELETE Audit Tables in SQL Server'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-1649402538063055066</id><published>2010-07-13T12:22:00.001-07:00</published><updated>2010-07-19T08:47:35.339-07:00</updated><title type='text'>Criteria for the current month in a query</title><content type='html'>The other day I needed to create a query where it returns all records with dates for the current month. I did not want to hard code the beginning and ending dates in the query, so I came up with the following line of code you can paste into your query:&lt;br /&gt;&lt;br /&gt;Between CDate(Month(Date()) &amp;amp; "/1/" &amp;amp; Year(Date())) And DateAdd("m",1,CDate(Month(Date()) &amp;amp; "/1/" &amp;amp; Year(Date())))-1&lt;br /&gt;&lt;br /&gt;The criteria line above uses the "Between And" operators to calculate the first of the month and the end of the month of the current date. Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-1649402538063055066?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/1649402538063055066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/criteria-for-current-month-in-query.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/1649402538063055066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/1649402538063055066'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/criteria-for-current-month-in-query.html' title='Criteria for the current month in a query'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-8454109963244783487</id><published>2010-07-13T12:21:00.003-07:00</published><updated>2010-07-19T08:51:41.119-07:00</updated><title type='text'>Bug will occur when using datasheet view in a sub form.</title><content type='html'>Here's a bug you will come across when using a subform in datasheet view:&lt;br /&gt;&lt;br /&gt;"Property Not Found"&lt;br /&gt;&lt;br /&gt;Here is the code that will trigger the criptic message from Access:&lt;br /&gt;&lt;br /&gt;Private Sub MyField_BeforeUpdate(Cancel as Integer)&lt;br /&gt;&lt;br /&gt;if somecondition = True then&lt;br /&gt;&lt;br /&gt;Msgbox "Your message here, usually you can't save the record because of something"&lt;br /&gt;&lt;br /&gt;Cancel = True&lt;br /&gt;&lt;br /&gt;end if&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;To fix the issue, replace Cancel = True with:&lt;br /&gt;&lt;br /&gt;DoCmd.CancelEvent&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-8454109963244783487?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/8454109963244783487/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/bug-will-occur-when-using-datasheet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/8454109963244783487'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/8454109963244783487'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/bug-will-occur-when-using-datasheet.html' title='Bug will occur when using datasheet view in a sub form.'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-358500651227052347</id><published>2010-07-13T12:21:00.001-07:00</published><updated>2010-07-19T08:52:10.341-07:00</updated><title type='text'>Access function to return day of the week</title><content type='html'>Sometimes you need the actual day name of the date and not the numeric equivalent, the following function will do that for you:&lt;br /&gt;&lt;br /&gt;Private Function MyWeekDayName(dteDate As Date) As String&lt;br /&gt;&lt;br /&gt;'Will return "Monday", "Tuesday", etc. based on the date supplied&lt;br /&gt;&lt;br /&gt;MyWeekDayName = WeekdayName(WeekDay(dteDate), False)&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Example use in debugger window:&lt;br /&gt;&lt;br /&gt;?MyWeekDayName(#10/19/2009#)&lt;br /&gt;&lt;br /&gt;Monday&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-358500651227052347?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/358500651227052347/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2010/07/access-function-to-return-day-of-week.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/358500651227052347'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/358500651227052347'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2010/07/access-function-to-return-day-of-week.html' title='Access function to return day of the week'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-5078261078599531995</id><published>2009-11-06T08:00:00.000-08:00</published><updated>2010-07-19T08:53:47.386-07:00</updated><title type='text'>How to create Outlook message from Access</title><content type='html'>Note: If you need to send out a massive amount of emails this code is not for you, instead we recommend FMS's Total Access Emailer.&lt;br /&gt;&lt;br /&gt;Note 2: You must add a reference to Outlook in your Access project in order for this code to work, if you need an alternate version that does not require it then look at the next section of this post below:&lt;br /&gt;&lt;br /&gt;Dim objOutlook As Outlook.Application&lt;br /&gt;&lt;br /&gt;Dim objOutLookMsg As Outlook.MailItem&lt;br /&gt;&lt;br /&gt;Dim strBody as String&lt;br /&gt;&lt;br /&gt;strBody = "Insert you body message here."&lt;br /&gt;&lt;br /&gt;Set objOutlook = New Outlook.Application&lt;br /&gt;&lt;br /&gt;Set objOutLookMsg = objOutlook.CreateItem(0) &lt;br /&gt;&lt;br /&gt;With objOutLookMsg&lt;br /&gt;&lt;br /&gt;.To = "w@what_Ever.com"&lt;br /&gt;&lt;br /&gt;.CC = "any@what_ever.com"&lt;br /&gt;&lt;br /&gt;.Subject = "Enter Your Subject Here"&lt;br /&gt;&lt;br /&gt;.Body = strBody&lt;br /&gt;&lt;br /&gt;.Send&lt;br /&gt;&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;Code without a reference to Outlook:&lt;br /&gt;&lt;br /&gt;Dim objOutlook As Object&lt;br /&gt;&lt;br /&gt;Dim objOutLookMsg As Object&lt;br /&gt;&lt;br /&gt;Dim strBody as String&lt;br /&gt;&lt;br /&gt;strBody = "Insert you body message here."&lt;br /&gt;&lt;br /&gt;Set objOutlook = CreateObject("Outlook.Application")&lt;br /&gt;&lt;br /&gt;Set objOutLookMsg = objOutlook.CreateItem(0) &lt;br /&gt;&lt;br /&gt;With objOutLookMsg&lt;br /&gt;&lt;br /&gt;.To = "w@what_Ever.com"&lt;br /&gt;&lt;br /&gt;.CC = "any@what_ever.com"&lt;br /&gt;&lt;br /&gt;.Subject = "Enter Your Subject Here"&lt;br /&gt;&lt;br /&gt;.Body = strBody&lt;br /&gt;&lt;br /&gt;.Send&lt;br /&gt;&lt;br /&gt;End With&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-5078261078599531995?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/5078261078599531995/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2009/11/how-to-create-outlook-message-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/5078261078599531995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/5078261078599531995'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2009/11/how-to-create-outlook-message-from.html' title='How to create Outlook message from Access'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3268512826072972755.post-5168486249582863226</id><published>2009-11-06T07:58:00.000-08:00</published><updated>2010-07-19T08:54:27.765-07:00</updated><title type='text'>Criteria for the current month in a query</title><content type='html'>The other day I needed to create a query where it returns all records with dates for the current month. I did not want to hard code the beginning and ending dates in the query, so I came up with the following line of code you can paste into your query:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Between CDate(Month(Date()) &amp;amp; "/1/" &amp;amp; Year(Date())) And DateAdd("m",1,CDate(Month(Date()) &amp;amp; "/1/" &amp;amp; Year(Date())))-1&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The criteria line above uses the "Between And" operators to calculate the first of the month and the end of the month of the current date. Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3268512826072972755-5168486249582863226?l=accessexperts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://accessexperts.blogspot.com/feeds/5168486249582863226/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://accessexperts.blogspot.com/2009/11/criteria-for-current-month-in-query.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/5168486249582863226'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3268512826072972755/posts/default/5168486249582863226'/><link rel='alternate' type='text/html' href='http://accessexperts.blogspot.com/2009/11/criteria-for-current-month-in-query.html' title='Criteria for the current month in a query'/><author><name>Juan Soto</name><uri>http://www.blogger.com/profile/17679676235428744290</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp2.blogger.com/_hw_qu0uUOok/R34p8RD5uDI/AAAAAAAAAPw/mJ7pn8wh-WE/S220/Juan%27s+Photo.jpg'/></author><thr:total>0</thr:total></entry></feed>
