Showing posts with label Access. Show all posts
Showing posts with label Access. Show all posts

Saturday, 15 February 2014

Updating Mouldings - Do it right!

I'll let you all into a secret - I get more questions and problems concerning updating Mouldings than anything else. So, this post is about doing things the right way.

First a few definitions -
  • Database - this is where the data is stored. It consists of (in our case) 4 interlinked "tables" These "tables" all contain "records". The "Customers", "MountBoard" and "Mouldings" tables all feed into the WorkTickets table. For instance, if a customer changes their address then you only need change it in the "Customers" table and all the associated WorkTicket records use that new address. Clever eh?                                                                                                               NB. The Basic version of Wessex Professional has the same database file, it just only uses the "Mouldings" table.
  • Database file - because our database is relatively small everything is stored in a single file ("v3.mdb"). The file is a Microsoft Access database file and can also be opened by Word or Excel.
  • Update file, contains data for the records in the Mouldings table - this is an Excel file (.xls) and is used to update a supplier in the Mouldings table.
The idea is to update the Mouldings table with the update file, bearing in mind that the mouldings table may have other data in that you want to preserve. So, it's not as simple as wiping the old data and replacing it with new data.

The program has always had in "File" -  "Import Database" and "Export Database" this is to allow the complete database to be copied & backed up, and to allow a backed up database to be re-installed. Unless you are doing either of those actions do not choose those options! If you do and don't heed the warning messages - you're on your own!

The up to date versions of the program also have under "File" - "Update Mouldings...". If you want to update your Wessex or Frinton records this is the option to go for.
(note - in older versions the same screen can be reached by going to "Setup" > "Options" choosing the database tab and clicking on "Bulk update from file".)

Now we just need to make a few decisions
  1. Which supplier we want to update, ie. Wessex or Frinton (or A N Other). Click the appropriate logo.
  2. Whether we just want to update the existing moulding records in the table or add all of the suppliers records to our own. (in my database I have all the Wessex records, because I can order any unstocked mouldings with my weekly delivery, but I only keep records of the Frinton mouldings I have in stock).
  3. Whether to add VAT to the wholesale cost of each moulding record (for those who are not VAT registered).
Click "OK" and you'll be asked to locate the update file (you did remember where you downloaded it to, didn't you?).
Once you've selected the correct file the bar at the bottom of the form will show you the progress. This is relatively sedate because the program first of all selects the existing mouldings and updates them individually. Then (if you've selected that option) it adds any new records that are in the fie but are not in your records. Finally, it looks to see if your records contain any mouldings that are not in the update file (if there are then they are marked, in the Notes section, "discontinued" with the date).

Note - any new records added are not marked as "Current". If you do stock them then you'll need to edit the individual record.
For some extra reading - have a look at this link , enjoy!

Friday, 3 May 2013

An interesting problem

The pricing program for PC (WPP4) has been behaving itself nicely. I've been working on a couple of minor improvements, including being able to create a file on mouldings that can be imported into the new Android App.
That was until a framer rang me up with a problem concerning the Invoice number.

The problem -
The invoice number can be increased in "Setup" > "Options". The idea was that you may not want to start with invoice number "1". However, this framer had a (quite reasonable) scenario of changing the invoice number to reflect her financial year, for example "1314001". She saved the new invoice number value and then tried to save an invoice - this produced an error and the invoice couldn't be saved. The problem was made worse because invoice number couldn't now be decreased in the "Options" form.

The reason for the error goes back to the original design of the database some 6 or more years ago. Each column in the database has a data type, for instance the"DateCollected" column in the table "WorkTickets" is datatype "date". Well the datatype of the "InvNum" column in "WorkTickets" is "integer". All well and good you think (well, I did anyway). But type "integer" in this form of database turns out to be "int16", a number made up of 2 bytes which has a maximum value of 32,787. A much better choice would have been "long integer" ("int32"). This number is made up of 4 bytes and has a maximum value of 2,147,483,647.

The Solution -
Once the data type has been set up in the design of the database it is very difficult to change. Certainly trying to change it programatically would be likely to throw up more problems than it solved. So, if you need to use numbers larger than 32,000 for your invoices here is what to do, "Export" your database and open this copy in Microsoft Access.
You will see a list of Tables at the left hand side. Choose "WorkTickets", the "WorkTicket" table and its data is now shown in the main pane. We want to get to the data types, so go to "Views" at the top left and choose "Design View". Now the Field (Column) names and their datatypes are displayed. Click on "InvNum" (second one down) and at the bottom of the screen its Field Properties are shown. The first one is "Field Size" as "Integer". Click on that line and from the drop-down box select "Long Integer" instead. Save the changes and close Access.
Now all that remains is to "Import" the modified database file back into the program. This will throw up a warning saying the database is corrupted, continue to import? (This is because we've changed the structure of the file.) Click "Yes" and the new database will be imported anyway.
You will now be able to use large numbers for your invoices.
Phew!

Saturday, 31 October 2009

A Database tweak


Fiddly things databases - just when you think you have everything just so, something else comes along to upset the balance.

I recently came across one such hiccup (or a least potential hiccup) in the "Mouldings" table of the Wessex Premier database.
The field "Supplier No" is structured not to allow duplicates. Now 99.9% of the time this will make no difference at all, in fact it can be very useful as it means that the mouldings which are duplicated between Wessex & Frinton cannot be duplicated in the program's database records. However, it could be that 2 different suppliers use the same number, or the user may want to show both the Wessex and the Frinton records.

So, how to solve the problem? I tried various programmatic solutions, but none worked consistently. So, given that most users probably wouldn't want to change the database file, what's the answer for those that do?

You'll need to use Microsoft Access (I tried this on Open Office Base, but no joy).
First of all "Export" (copy) the database file (called "V3.mdb") to a suitable location, as it's always best to work on a copy rather than the master file.
Double-clicking the file will open it in Access (assuming that is your default database program). On the left hand side you'll see a list of the tables ("Customers", "WorkTickets" and so on) Double-click the "Mouldings" table to open it. A chart with all the records will be displayed.
In the top left just above the table list is "Views", click this and select "Design View". The main window will now show a list of the fields in the Mouldings table and their properties. (see below)


Select "Supplier No". Below is a list of the properties for that field.
Select "Indexed" and change "Yes, (No Duplicates)" to "Yes, (Duplicates OK)".
"Save" the changes and you're done, all that remains is to "Import" the modified file back into Wessex Premier.

Points to note -

You should regard this "tweak" as one way only, because, once you have added a record with the same supplier number as another record, Access will not allow you to change back.

You change any of the other properties at your peril!

The above screenshot was from Office 2007, be sure, however, to save the database as an Access 2000/2003 file (ie. a .mdb file not a .mdbx file).

The steps in Office 2003 look different, but are basically the same. (If that's not too double-dutch!)