ZEND Framework in Action – Review

I will keep this very short and to the point.

I recently purchased a series of books, one of which was:

ZEND Framework in Action by Rob Allen, Nick Lo & Steven Brown, published by Manning with a total of 401 pages.

I can’t quite explain it, but something just doesn’t work. I seem to end up reading 3-4 times the same sections as if I am continually missing some key piece of information to allow me to actually understand and follow?! They cover everything I wanted to learn, but it just doesn’t seem to be complete. It just doesn’t seem to flow like other books I have read.

For instance, I had to go online to find out how to generate the ZEND directory structure, they seem to make a lot of assumption and/or skip over certain basic issues that, in my humble opinion, need to be part of the book to make it complete! I say this as I am also reading another book about CodeIgniter, which makes this one pale in comparison.

Case and point, I have been unable to date, to create a functional version of the helloworld example as explained in chapter 2 of the book! I keep getting errors no matter what I try. This book has ended up being more frustrating than anything else.

I think for a beginner looking to learn from scratch, this book leaves a lot to be desired. I’d keep looking. For an intermediate Zend developer, this book may be more appropriate.

I am still trying to complete the entire book and will post back with a final verdict.

MS Access – AutoNumber Field

We tend to see numerous questions relating to MS Access Autonumbers. Specifically, regarding autonumber not following sequence, skipping sequence.

What Are AutoNumbers and What Aren’t They!

Regardless of how one might interpret what is written in the help files, AutoNumbers should never, ever, ever, be relied upon as a sequential number. Nor should they ever be used/displayed to the end-user. The simple fact of the matter is that AutoNumbers are merely unique identifiers for each record. Even when set to be incremental, the AutoNumber can be indexed even though no record was actually inserted into the table. This is not a bug, this is simply the way Access was developed.

Sequential Numbering

So what does one do if they require a sequential number to attribute to each record.

The solution is actually very simple. Create a new numeric field in your table and then you can used an equation such as =Nz(Dmax(…), 0) + 1 to generate the next number in your sequence. At the end of the day, if you want a sequential number that will not jump sequence and can be faithfully relied upon, you have to create it yourself!

VBA – Determine if a Folder/Directory Exists or Not

Icon of a Folder with a Check-mark on it

It can often come handy to be able to quickly determine if a Folder/Directory exists or not (especially before trying to use it for something!). Below are a few possible approaches that can be employed to check the existence of a folder/directory using VBA:

I have recently updated them to include an optional parameter to create the folder should it not be found.

Continue reading

VBA – Create Directory Structure/Create Multiple Directories/Create Nested Directories

One of he most common methods for creating directories/folders in VBA is to use the MkDir statement. For instance:

MkDir "C:\databases\"

One quickly learns the limitations of this technique the minute they have to create a directory structure with multiple sub-folders. MkDir can only create 1 directory at a time and cannot create a sub-directory. Hence, assuming that C:\databases does not already exist, the following would not work and will return an error!

MkDir "C:\databases\msaccess\"

If you absolutely want to create such a structure using the MkDir statement you’d have to do so using 2 MkDir statement. For instance:

MkDir "C:\databases\"
MkDir "C:\databases\msaccess\"

Now if you need to merely create 1 or 2 sub-folder MkDir may still be acceptable, but there are cases where this is simply impracticable and another solution needs to be found. Well, I found 3 possible alternate approaches that I thought I’d share today.

Continue reading

Brother HL-2270DW Laser Printer – Review

So a couple months ago, I finally broke down and bought a new printer since Windows 7 x64 didn’t support my existing printer. After perusing the weekly flyers and speaking with a good friend, I ended up purchasing the Brother HL-2270DW. Below are my thoughts on the printer after several months of usage.

 

Pros

  • Extremely faster printer (up to 27 page per minute)
  • Wakes up fast from sleep mode
  • Decent size paper tray (250 sheets)
  • Easy duplex printing without the need of manual intervention on the part of the user
  • Relatively cheap toner (when compared to my previous printer – about half the cost for the same yield)
  • Good quality printing (from my perspective)

 

Cons

  • No USB cable supplied (although it is a wireless printer, it is recommended for the installtion)
  • I found the installation process ‘confusing’ referring to terms the average user will not know
  • Envelop printing is very poor as it crumples the envelop (unacceptable for business purposes)

In conclusion, I like this printer, but am disappointed with the envelop print quality. If I had to give it a grade it would be 88/100. All in all, it is a good printer for individual and small business use.

SEO Companies – SEO Optimization Service E-mails

If you own a website, you undoubtibly have received beautiful SPAM e-mails from various sources offering you their Search Engine Optimization (SEO) services. Now the following points may be obvious to some, but I thought I’d put them black on white for people who are new to the field, or are simply not aware of a few things in the www.

so you’ve received and e-mail such as (just a few examples)

We offer quality Search Engine Optimization / SEO Services and Internet Marketing Solutions. Our dedicated team of SEO Professionals ensures Top 10 search engine rankings. Our SEO Processes are designed in view of the SEO guidelines, and white hat SEO techniques are strictly followed to ensure that our clients from world over get the best SEO services. Please reply to this email so we can send you more details.

We will optimize your site to increase its rankings with major search engines. This will drive targeted online users to your site, as well as attract new users through the use of relevant keywords and phrases. Not only will we help you gain those higher rankings, but maintain your status through continual management and support. Please reply to this email so we can send you more details.

We noticed that you are not at the top of the search engines for a number of your key terms. We have helped companies similar to yours to achieve top organic rankings. Please reply to this message and we will prepare a special proposal for you, to show you how we can achieve similar results for you.

We are interested to increase traffic to your website, please get back to us in order to discuss the possibility in further detail.

We strongly believe that we have an excellent opportunity to increase the number of visitors to your website through our white-hat SEO services. Please simply reply to this message and we will be delighted to send you further information.

Search Engine Marketing will increase your company’s online presence through comprehensive online marketing campaigns, targeted search engine optimization, and highly managed internet marketing promotions. A search engine marketing campaign will encompass several procedures and factors to make it successful. Please reply to this email so we can send you more details.

We are a leading India based SEO company providing the best search engine optimization services. We act as your business partner and helps you reach your business goals. We promote websites no matter who you are – a huge company with thousands of employees, a small business or a professional who offers professional / consulting services. Let us know if you are interested and we will get back to you with more details.

Hello,

Greetings for the day!

I am xxxxxxx and I am contacting you after looking at your website- .

We are a Leading Indian Based SEO & Web Development Company and one of the very few company which offer organic SEO services with a full range of supporting services such as one way themed text links, blog submissions, directory submissions, article writing and postings, etc.

We are a team of 50+ professionals which includes 18 full time SEO experts. We are proud to inform you that our team handled 100+ SEO projects and obtained 40000+ manually built links in the past 1 year.

We will be glad to assist you with offering our services. Please let me know your Interest so that we can tell you more about Our Services.

Thanks
—————-
xxxxxxx xxxxxxxxxx
Online Marketing Consultant

Now there are a couple reasons why I would never deal with any of these companies:

  1. Firsty, they sent me SPAM!
  2. If I can’t be found on search engines, then how did they find me in the first place?
  3. They always use gmail, hotmail, live e-mail accounts. If they truly were a reputable company they would use their own corporate e-mail address. For me they represent fly by night companies that I would avoid at all cost.
  4. Similarly, in many cases, the e-mail address name does not match the sign-off name in the e-mail. Makes me wonder?!
  5. Why hire a company to do what you can do yourself? SEO is very basic and there are no tricks that they possess that you cannot do yourself with a little time.
  6. Most importantly, any company that promises specific results I would avoid at all costs! No one can guarantee where you will show up on any search engine since the equations behind indexing are private and always changing. A SEO consultant can say they will optimize your site, and should be able to improve your ranking, but to say you will end up on the 1st page is just ridiculous!

Also, please remember that you can’t be at the top of search engine searches for every keyword! So anyone can always claim that you are not at the top of search engine ranking for some keyword. You have to concentrate your efforts on a select group of keywords and work your site around the keywords you have chosen.

Another important thing to note about SEO is that it is an on-going process. There is always more that can be done. So it is important to fix a realistic goal and aim for that. Once you have done your SEO, you should then review your site statistics for a couple week or months, and then define a new attack plan.

At the end of the day though, if you want to get someone to do some SEO for you that is fine, but find yourself a web developer through your network, yellow pages, the person that developed your site. Then validate there abilities by asking for examples and references (anyone can claim to be a SEO expert). Just stay away from the SPAM, unsolicited SEO as they are questionable (refer to the list above).

MS Access – VBA – Open/Browse a Folder

So you merely would like to navigate to a given folder! Well, as usual, there are numerous ways to accomplish this.

Method 1 – FollowHyperlink Method

The first method is to use the FollowHyperlink Method. This is a great technique because it requires minimal coding and will open the folder in the user’s default software of choice. The code would look something like:

Application.FollowHyperlink "C:\Program Files\Microsoft Games"

Method 2 – Shell Function

You can use the Shell Function to specify which program to use and pass it whatever variable that application accepts. So for our needs, we can merely use Windows explorer to open the folder we are interested in. The code would look something like:

Dim sPath as String
sPath = "C:\Program Files\Microsoft Games"
Shell "C:\WINDOWS\explorer.exe """ & sPath & "", vbNormalFocus

In the case of the FollowHyperlink Method, you obviously have to ensure that your users’ actually have the program you are trying to utilize to open the folder and be careful with the exe location since it may change depending on OS versions, but you can easily build a more robust function to handle all these exceptions/cases.

MS Access – VBA – Retrieve a Random Record

Another interesting question I was once asked on an Access forum was how can one retrieve a random record in a form?

I was actually perplexed as to how to approach this request, but it really isn’t that complicated at the end of the day. The code below demonstrates one possible method.

'---------------------------------------------------------------------------------------
' Procedure : GetRndRec
' Author    : Daniel Pineault, CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Purpose   : Goto/retrieve a random record
' Copyright : The following may be altered and reused as you wish so long as the
'             copyright notice is left unchanged (including Author, Website and
'             Copyright).  It may not be sold/resold or reposted on other sites (links
'             back to this site are allowed).
'
' Revision History:
' Rev       Date(yyyy/mm/dd)        Description
' **************************************************************************************
' 1         2008-Dec-21             Initial Release
'---------------------------------------------------------------------------------------
Function GetRndRec()
On Error GoTo Error_Handler
    Dim db          As DAO.Database
    Dim rs          As DAO.Recordset
    Dim tblName     As String   'Table to pull random record from
    Dim iRecCount   As Long     'Number of record in the table
    Dim iRndRecNum  As Integer
    
    tblName = "YourTableName"
    Set db = CurrentDb()
    Set rs = db.OpenRecordset(tblName, dbOpenSnapshot, dbReadOnly, dbReadOnly)
    
    If rs.RecordCount <> 0 Then 'ensure there are records in the table before proceeding
        With rs
            rs.MoveLast   'move to the end to ensure accurate recordcount value
            iRecCount = rs.RecordCount
            iRndRecNum = Int((iRecCount - 1 + 1) * Rnd + 1) 'Get Random Rec Number to use
            rs.MoveFirst
            .Move CLng(iRndRecNum)
            GetRndRec = ![YourFieldName]
        End With
    End If

Resume Error_Handler_Exit
    On Error Resume Next
    'Cleanup
    rs.Close
    Set rs = Nothing
    Set db = Nothing
    Exit Function

Error_Handler:
    MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
           "Error Number: " & Err.Number & vbCrLf & _
           "Error Source: GetRndRec" & vbCrLf & _
           "Error Description: " & Err.Description _
           , vbOKOnly + vbCritical, "An Error has Occurred!"
    Resume Error_Handler_Exit
End Function

MS Access – VBA – Determine in Which Table a Field is Located

This was the question put forth by someone on an Access Forum recently and I thought I’d share one possible way to determine this.

This is a brute force method, but it works! I simply loop through all the tables one by one and loop through all the fields within each table one by one. It is that simple. Here is the code.

'---------------------------------------------------------------------------------------
' Procedure : WhereFieldLocated
' Author    : Daniel Pineault, CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Purpose   : Determine/Locate in which Table(s) a field is located
' Copyright : The following may be altered and reused as you wish so long as the
'             copyright notice is left unchanged (including Author, Website and
'             Copyright).  It may not be sold/resold or reposted on other sites (links
'             back to this site are allowed).
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' sFieldName: The name of the field you are trying to locate
'
' Usage:
' ~~~~~~
' WhereFieldLocated "Filed1"
'
' Revision History:
' Rev       Date(yyyy/mm/dd)        Description
' **************************************************************************************
' 1         2011-Aug-17                 Initial Release
'---------------------------------------------------------------------------------------
Function WhereFieldLocated(sFieldName As String)
    Dim db            As DAO.Database
    Dim td            As DAO.TableDefs
    Dim fld           As DAO.Field

    Set db = CurrentDb()
    Set td = db.TableDefs
    For Each t In td    'loop through all the tables in the database
        If Left(t.Name, 4) = "MSys" Then GoTo Continue
        For Each fld In t.Fields    'loop through all the fields of the table
            If fld.Name = sFieldName Then
                Debug.Print t.Name
            End If
        Next
Continue:
    Next

    Set fld = Nothing
    Set td = Nothing
    Set db = Nothing
End Function

VBA – Open a Password Protected Excel WorkBook

I recently helped an individual in an Access Forum who wanted to know how to open a password protected Excel workbook/spreadsheet. Although the question was Access specific, the code can easily be used in Word, PowerPoint,…

'---------------------------------------------------------------------------------------
' Procedure : OpenPwdXLS
' Author    : Daniel Pineault, CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Purpose   : Open a password protected Excel Workbook
' Copyright : The following may be altered and reused as you wish so long as the
'             copyright notice is left unchanged (including Author, Website and
'             Copyright).  It may not be sold/resold or reposted on other sites (links
'             back to this site are allowed).
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' strWrkBk  : Full path and Filename of the Excel Workbook to open
' sPwd      : Password to unlock/open the Workbook in question
'
' Usage:
' ~~~~~~
' OpenPwdXLS "C:\Testing\book1.xls", "MyPassword"
'
' Revision History:
' Rev       Date(yyyy/mm/dd)        Description
' **************************************************************************************
' 1         2009-Jun-11             Initial Release
'---------------------------------------------------------------------------------------
Function OpenPwdXLS(strWrkBk As String, sPwd As String)
'Use late binding so no reference libraries are required
On Error GoTo Error_Handler
    Dim xlApp       As Object
    Dim xlWrkBk     As Object

    On Error Resume Next
    Set xlApp = GetObject(, "Excel.Application") 'Bind to existing instance of Excel
    
    If Err.Number <> 0 Then
        'Could not get instance of Excel, so create a new one
        Err.Clear
        On Error GoTo Error_Handler
        Set xlApp = CreateObject("excel.application")
    Else
        On Error GoTo Error_Handler
    End If

    xlApp.Visible = True 'make excel visible to the user
    Set xlWrkBk = xlApp.Workbooks.Open(strWrkBk, , , , sPwd)
    
    '... the rest of your code goes here
    
Error_Handler_Exit:
   On Error Resume Next
   Set xlWrkBk = Nothing
   Set xlApp = Nothing
   Exit Function

Error_Handler:
   MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
          "Error Number: " & Err.Number & vbCrLf & _
          "Error Source: OpenPwdXLS" & vbCrLf & _
          "Error Description: " & Err.Description _
          , vbOKOnly + vbCritical, "An Error has Occurred!"
   Resume Error_Handler_Exit
End Function