QuickBooks® - QODBC Quick Start Part 7 for Beginners

This is part of a tutorial on how to create a Microsoft® Access customer database with a live link to QuickBooks® using QODBC with copy and paste code, screenshots and instructions. The tutorial begins here.


The previous post explained:
  1. how Microsoft® Access reacts when you try to overwrite a table used as a record source.
  2. how to incorporate Visual Basic code that:
    1. clears the form's record source to avoid errors when recreating the table
    2. calls a function that recreates the form's record source

Record Source Function

Copy this Function and paste it into the Visual Basic Editor of your form.

Remember, the reason for this function is to change the form's record source from anywhere in your form's code by typing: fncForm_RS.

Hint: The _RS extension of this function's name tells you it changes a record source. Coding functions and procedures with extensions let's you find them quickly when reprogramming or debugging.
Function fncForm_RS()
'if an error occurs, go to the error line to report it
On Error GoTo Form_RS_err
'set the form's record source to the reloaded customer table and orders the customer alphabetically by name
Form.RecordSource = "select * from tblCustomer_reloadable order by name"
'return to the procedure
Exit Function
'come to this line if an error occurs
'print information about the error in the immediate window
Debug.Print Err.Number & " " &; Err.Description
'display the error to the user in a message box
MsgBox Err.Number &; " " &; Err.Description
End Function

Now if you learn more VBA and want to change the record source, you only need to change the Function. This habit of creating separate functions or procedures for record sources saves time.

For example, you may decide to program a control to search for customers. In that case, you would rewrite the record source function to use criteria. Then you would call the function for each search. If this is beyond you, do not worry. All you need to do is copy and paste. If you read the green notations, you will also learn as you go.

Test the Button

Here is a fun way to test your new button.
  1. Open the customer center in QuickBooks®.
  2. Create a new test customer with some fake information. Hint: Begin the customer name with an asterisk (*) to make it appear as the first customer on your form.
  3. Return to the Microsoft® Access database and click the reload button.
  4. Look for the new test customer.
  5. Return to QuickBooks® and delete the test customer.
  6. Return to the form and click the reload button again to see that the customer is no longer there.
Notice that during the time the form's record source is set to nothing, #Name? appears in all the text boxes instead of data as illustrated below.

After the form's record source is reset, data appears in the text boxes again.

If you did not begin the test customer with an asterisk, you may need to scroll the form to find the test customer.

You now have a Microsoft® Access customer database with a live link to QuickBooks® using QODBC. You simply refresh customer data with the click of a button.

If you haven't redesigned the form to your liking, you may do that now. That is the beauty of doing your own programming.

Hint: I like to use pretty colors and fun clip art to keep work interesting.

Remember, the main reason for creating a customer form in Microsoft® Access is:

  1. to provide you with as many additional customer fields as desired
  2. to create a contact table so that each customer may have as many contacts as needed.


Next you will learn how to add additional fields and link them to your customers. There are two reasons for using QODBC:
  1. a quick, live link without the need for importing IIF files or Microsoft® Excel spreadsheets
  2. QODBC gives you access to QuickBooks® ListIDs that make excellent unique identifiers because:
    1. QuickBooks® assigns them
    2. they are unique
    3. they are permanent.
Your database will use these ListIDs to link customers to additional records in your database.

Continue to the next post… or return in a day or two for the next installment. Check http://www.twitter.com/vbquick for news and updates.


Popular Posts