3/12/2013

Backup of SQL Server databases from within Microsoft Access

no image

Sent to you by DuyTuan via Google Reader:

via Tony's Microsoft Access Blog by Tony on 12/16/12

WARNING:  Some of the following instructions may not be best practice.    This is a personal database so I can afford to take some shortcuts and not do thorough research.  If you do use these tips and sample code in production check back in a week and a month to see if there are any changes or comments.

Objective

I wanted to create a method of backing up a personal SQL Server database from within Access.   In a production environment you'd have tasks which ran on a regular basis, i.e. at midnight or whatever, that would do this.  But here I might update some records every few days and wanted to do this on my schedule.
Note that, as the names of the stored procedures indicate, I will be modifying these as I add more functionality such as database checks, log truncation, etc.

General SQL Server setup tips

10/11/2012

View system tables in database window

no image Question: In Access 2003/XP/2000/97, how can I view system tables in the database window?
Answer: Under the Tools menu, select "Options".

10/09/2012

Hide tables as system tables in Access

no image Question: I've created an Access 2003/XP/2000/97 database and flagged all of the tables as hidden objects. The users have figured out how to display these hidden tables. Is there any way that I can keep my tables from being displayed in the database window?
Answer: If you've tried setting your tables as hidden objects and the users are still able to find them, you can always set your tables up as system tables. Inside of your Access database, there are several system tables that even you can't see. These tables are used internally by the Access database.

10/07/2012

Hide tables as hidden objects

no image Question: In an Access 2003/XP/2000/97 database, I've created a table that I don't want others to see. How can I hide a table from appearing in the database window?
Answer: If you don't want users to see a table in an Access database, you can mark the table as a hidden object.

Open the database exclusively

no image Question: In Access 2003/XP/2000/97, I tried modifying some of the objects in my Access database and I received an error message stating that I needed to open the database exclusively. What does this mean and how do I open a database exclusively?
Answer: Because Access was designed to accommodate multiple users in the system at the same time, you may need to have exclusive access to the database to modify forms, tables, etc. depending on the circumstances.

Display/Unhide the database window

no image There are different ways that the database window can be hidden in Access 2003/XP/2000/97. As a result, there are also different methods for displaying a hidden database window. We'll go through the options from the easily method to the most difficult.

Method #1

This is the easiest and most common method of unhiding a database window.
Under the Window menu, select Unhide.

10/05/2012

Hide the database window

no image
There are different ways that the database window can be hidden in Access 2003/XP/2000/97. We'll go through the options from the easily method to the most difficult.

Method #1

This is the easiest and most common method of hiding a database window.
Under the Window menu, select Hide.
copyright www.TechOnTheNet.com
With this method if a user chooses to display the database window, it will remain visible even if the user closes down the database file and reopens it.

9/05/2012

Bind combo box to primary key but display a description field in Access

no image Question: In Access 2003/XP/2000/97, I've set up a table that contains an autonumber field as the primary key and a description field. I want to be able to create a combo box that displays the description, but stores the primary key. How do I set up the combo box?
Answer: Quite often the primary key value can mean nothing to the user. Instead, there is a description field in the table that relays the meaning of the record. In Access you can link a combo box to the primary key, but display the description in the combo box itself.
To do this, first create a combo box object. Right-click on the combo box and select Properties from the popup menu.

8/24/2012

DateDiff Function

no image In Access, the DateDiff function returns the difference between two date values, based on the interval specified.
The syntax for the DateDiff function is:
DateDiff ( interval, date1, date2, [firstdayofweek], [firstweekofyear])
interval is the interval of time to use to calculate the difference between date1 and date2. Below is a list of valid interval values.

8/16/2012

View only records with uppercase letters for a certain field in Access

no image Question: In Access 2003/XP/2000/97, if I wanted to view only the records with Uppercase letters for a certain field, how would I do it?
For example, the query would ignore "Bob", but show "JOHN".
Answer: Access was built to be case-INSENSITIVE, but we can always use the ASC function to determine upper vs lower case.

Calculate and format an elapsed time value in Access

no image Question: In Access 2003/XP/2000/97, how do I format a time on a report so it appears as elapsed hours and minutes?
For example, 27 hours and 31 minutes appears as 27:31. I can do this for values up to 24 hours. But for anything over 24 hours, the full day(s) are dropped off.
Answer: A "elapsed time" is usually calculated by taking the difference between two dates. So, you will need to store the "from" and "to" dates separately and then calculate the elapsed time.

8/06/2012

Convert currency into words

Convert currency into words Question: In Access, how can I convert currency to words?
For example,
$100 should read as "one hundred exactly"

Answer: To convert currency into words, you'll need to open your Access database and create a new module.

8/05/2012

Generate a random number between 2 user-specified values

Generate a random number between 2 user-specified values In Access, the Rnd function allows you to generate a random number (integer value). You can specify the random number to be a value between 2 user-specified numbers.
The syntax for the Rnd function is:
Int ((upperbound - lowerbound + 1) * Rnd + lowerbound)
upperbound is the highest value that the random number can be.
lowerbound is the lowest value that the random number can be.

8/04/2012

Report Example (Employee hours worked per day)

Report Example (Employee hours worked per day) Question: In Access 2003/XP/2000/97, I have a database where I report employee hours daily. I need a report that displays the hours worked daily and the total of hours worked per week per employee.
Answer: We've created a sample Access database that contains the tables, queries, and reports required to demonstrate this example.

8/03/2012

Display parameter values in a report based on a parameter query

Display parameter values in a report based on a parameter query Question: In Access 2003/XP/2000/97, how do I display parameter values in a report based on a parameter query?
Answer: To display a parameter value in a report, you will need to redesign your parameter query to return the parameter as a field in the result set.
We've created an Access sample that you can download.

8/01/2012

Capitalize each word in a string (similar to InitCap in Oracle)

Capitalize each word in a string (similar to InitCap in Oracle) In Access, the StrConv function returns a string converted as specified.
The syntax for the StrConv function is:
StrConv ( text, conversion, LCID )
text is the string that you wish to convert.

7/31/2012

Renumber invoices with VBA code

no image Question: In Access 2003/XP/2000/97, I have a database which contains a large number of records. Each week, I need to renumber the INVOICE NUMBER field in a table named DATA with a new batch of numbers.
Answer: You can renumber your invoice numbers using a custom function.
Open your Access database, click on the Modules tab and create a new Module. Paste in the following

7/24/2012

Change AutoFormat (background style) for a form in Access

Change AutoFormat (background style) for a form in Access
Also learn how to change AutoFormat (background style) for a form in Access 2007 | Access 2003/XP/2000/97.
Question: In Access 2003/XP/2000/97, is it possible to change a background style for a form?
Example: I have a user who wants to change the background throughout the application. When it was originally created the autoformat "Expedition" was utilized.
Answer: You can change the background style of an object using an AutoFormat. To do this, open the form in design view. In this example, we've opened the form called Customers.

7/22/2012

Prevent the mouse wheel from scrolling through records in a form in Access

Prevent the mouse wheel from scrolling through records in a form in Access Question: In Access 2003/XP/2000/97, how do I prevent the mouse wheel from scrolling through records in a form?
Answer: You'll have to download the following MouseWheel.dll file and copy it to each computer that you wish to prevent scrolling.