|
|
|
Viewpoint
Datahandling for students
Frequently Asked Questions
- Users' Questions:
- Additional Questions:
-
| User Questions: |
| Q.What versions of Viewpoint are there? |
| A. |
Viewpoint only acquires new version numbers when it acquires new features; maintenance releases keep the same version number and only the date (in the Info box) changes. The current version number is 1.0. |
|
|
| A. |
There are several ways to do this. One way is to write a script to do this kind of manipulation.
The best of the immediate solutions is to change the design of your database, so that what's stored isn't the school year they're currently in, but the calendar year in which they started school. You can then work out what year they're in using two formula fields, one to work out what academic year it is at the moment:
monthof(today) > 8 => yearof(today) : yearof(today)-1
This formula will give "2001" for dates between September 2001 and August 2002, which is probably just what you need to give the academic year. If this formula field is called 'year now' and the integer field giving the academic year the pupil started is called 'year started', then the formula for which year the pupil is in now would be:
1 + 'year now' - 'year started'
This will give "1" for pupils who started school this academic year, "2" for those who started it in the previous one, and so on. Pupils who are kept back a year or accelerated a year will require you to tell a little white lie in the 'year started' field! (As Brett Lanoish has pointed out to us, this only works for primary schools -- if you're a UK secondary school you will want to add six to this so that your intake year is 7 and so on up the school, as per UK National Curriculum).
The moral of the story is this: if you've got a value which changes from time to time, but you can calculate it from another value which doesn't change, then store the unchanging one in the database and calculate the changing one when you need to use it. That way you don't involve yourself in lots of work every September!
-- "But it's too late! I've already got a 2,000-record database with the current academic year in!"
Not a problem. You can set up a formula field that goes the other way, and calculates the 'year started' field from the 'year now' field, using the formula:
1 + yearof(today) - 'year now'
Once you've added this formula field in the layout editor, click OK and it will be added to your database. Then go back into the layout editor, change its type to Integer (by clicking on it, then clicking on the "12" icon) and click OK again. It'll magically become an integer field with the right value in. Then all you need to do is go into Layout view again, remove the field's formula (Shift-Ctrl-G, Ctrl-U, Return) and turn the 'year now' field into a formula field depending on the 'year started' field, as outlined above.
That, admittedly, all adds up to quite a complex procedure, but, once it's done, not only have you solved the Year problem for this school year, but it'll solve itself each year from now on!
|
Q. |
How can I alter the order of the layouts in the list? |
A. |
The only way to reorder the layouts is to copy them one by one to the end of the list, and then delete the original versions. To copy a layout, use the New layout command on the view menu, giving the new layout the same name as the old one. Of course, you'll have to be careful not to delete any layouts that you haven't yet copied!
|
Q. |
How do I set a layout other than the first in the list to be opened by default? |
A. |
Basically, you can't do this - the first layout in the list is always the first to be opened. However, you can reorder the list as described above, so it's always possible to get the layout you want to be opened first.
If you're using passwords, it is also possible to get different classes of user to see a different layout initially, since it's the first accessible layout in the list that's used by default.
|
Q. |
I'm trying to import a CSV file which I made on a PC, and Viewpoint's refusing to accept it. |
A. |
If the error you're getting is 'Invalid character in CSV file' then you may be falling foul of DOS's unpleasant habit of putting Ctrl-Z (ASCII 26) characters at the end of text files.
|
Q. |
My database takes ages to display each record. Got any tips? |
A. |
If you've got lots of formula fields in your database, yet the values, once they're put in the fields, never change, consider making the fields text or numeric instead, but giving them the formula as a default formula. Fields are re-evaluated from the default formula every time they are found to be null, i.e. when the record is first created, and afterwards if you put the cursor into that field and delete everything in it.
Changing a formula field into an ordinary field with the same formula, is as easy as selecting it (while in the layout editor) and clicking on the type you want it to be in the toolbox pane to the left of your page.
|
Q. |
How come when I 'Save as Report' all my fields get chopped off at the end? |
A. |
Viewpoint's 'Save as Report' option saves the database as a text file, but a text file which is the nearest equivalent of the graphical view you can see on screen. That's to say, it rounds all the fields' positions and sizes to the nearest whole number of characters in each direction. In doing this, it doesn't take account of how much data is actually in the field, just how big the box is on the screen. Fields where the text is in a really small point size may well be truncated in the report.
That's not a bug (honest!), it's as well as it's possible to do when building a text file from a complex graphical layout. (You'd want to do this, for instance, if you were going to print the text file on a character-only printer such as a daisywheel or line-printer.) If you want to save out your data looking exactly like it is on screen, you should use 'Save as...' Viewpoint (.vpf) file instead.
|
Q. |
I had a database which for ages was about xxxK long. Now I look and it is twice as big. What has happened? |
A. |
What has happened is, you have re-sorted the database. This restructures the whole file in place, which can lead to fragmentation - the free space isn't 'lost', it'll be used eventually, but it's not being used at the moment. If you want to get back to having a nice, neat, optimally-packed database file, you can use the Save option on the menu to create a copy of the database, and use that copy instead. The Save option builds the file again from scratch using the new sort order, so it gets built optimally.
More rarely, the same effect can also be observed if you've been adding and deleting lots of records. Using the File=>Reorganise file option to make a new copy can occasionally recover lots of space.
|
Q. |
Got any documentation on the Viewpoint file format? |
A. |
The Viewpoint file format is complicated. It's based on the ISAM (Indexed Sequential Access Method) format and is full of n-ary trees amongst other jargon. The Viewpoint engine itself went through millions of test cycles, some of which threw up ridiculously obscure ways in which it was possible to get it wrong (now, of course, all fixed).
|
| Q. |
How do you install Viewpoint on an NT Server? |
| A. |
If you wish to install Viewpoint on an NT Server for loading onto your client machines, you still need to install it on each client as there are DLL files that need transferring to the local Windows directory, and entries to be made to the Registry.
However it can be substantially quicker to install, and much simpler to upgrade if you ensure that you always install to the same path on the server. To do this, when you get to the 'Choose Destination Location' page, use the 'Browse' button to browse to a suitable shared directory on your server and always install to the same location from all clients.
In that manner, when it comes to upgrading, the Viewpoint.exe file only needs to be replaced once. There is little network overhead, as Viewpoint is a relatively small executable by Windows standards, and loads quickly. |
| |
Additional Questions: |
Q. |
Sorting |
A. |
The sort can be saved and selected when the file is reloaded but the file itself will not automatically be sorted. Can you help?
The problem here is that Viewpoint allows multiple sort orders, whereas other databases only allowed the underlying records to be sorted, which meant there was only a single sort order active at any one time.
When you perform a sort under Viewpoint, it behaves much more like a subset, in that you can toggle between the new sort order and the old one, and the sort is lost if you close the database.
To make the sort order permanent, you need to give your query a name by entering one in the toolbar at the top of the window when you set up the sort order, then attach that query to your layout so that it is used by default.
To attach a query to a layout, you need to be in Layout view, then chose Query/Table=>Attach to=> <queryname> from the menu.
Note that each layout can have a separate sort order if you want, so if you want all your layouts to have the new sort order you need to attach each in turn to the named sort query.
If you want the sort order to be maintained permanently, so it is stored in the main database and is immediately available when you reload the database (rather than being recalculated when you open it), you should set the 'Keep index' flag in the toolbar.
When you perform a sort, Viewpoint creates a 'secondary index' in the order you specify, which is then used to fetch the underlying records in the table in the order desired. The order of the underlying records does not change. This allows you to set up a number of alternative sort orders and switch quickly between them, as you can just choose your desired sort order from the Query=>View/Run menu, or even attach scripts to buttons on the background of your layout to switch to a given sort order.
Viewpoint can also sort the underlying records in this way, if you want it to - you need to edit the layouts and choose Query/Table=>Edit=>Clustering key. However, since all secondary indexes must store the clustering key of each record, you should be careful not to use a very long clustering key. |
Q. |
Searching |
A. |
I searched for some records within my database, and now I can't get my other records back. The subset button hasn't appeared, so I can't seem to turn it off.
What's happened here is that you have probably performed a search while in Edit Layout mode.
If you do this, Viewpoint creates a permanent query called 'Join for layoutname', and attaches the layout to that query.
This means that the layout shows the records that are returned by the query, rather than those from the underlying table. The other records are still there, but you won't be able to see them using that layout.
This behaviour is in contrast to what happens if you perform a search in browse mode, where Viewpoint will normally just create a temporary query on top of the table or query that the layout is attached to, and you can toggle between this query and the original query by clicking on the 'Subset' button.
If you've performed the search while in Edit Layout mode, however, the subset button will not come on unless you perform another search while in browse mode, and this search will only return records from within the original search, as the original/initial query will already have your original search applied to it.
Why is this behaviour useful?
Well, it allows you to create layouts that only show certain records: for example, you could have a layout showing overdue library books.
In a similar way, it also allows you to have different sort orders in different layouts, since the sort order is just another aspect of a query.
OK, I see what you're saying. Now how do I get my records back?
Answer: If you want to revert to showing all the records from the underlying table, you need to edit the layout, and then either choose Query/Table=>Attach to=>TableName, or, if you don't want to keep your query, choose Query/Table=>Search, then click on Delete in the toolbar to delete the query, and click Cancel in the toolbox to return to Layout view. At this point Viewpoint will realise that the underlying query has been deleted, and will automatically re-attach the layout to the main table within that query.
|
Q. |
Merging |
A. |
I am trying to update some records by importing a CSV file using a Clustering key, but I can't get it to work: Viewpoint reports the error:
'To use 'Match Sort Key' you need to set the Clustering key of the destination table'.
Basically you need to make sure you're importing into a layout that's attached to a table, rather than a query, and then you need to set the clustering key (i.e. the underlying sort order) of the table records.
To check that the layout is attached to a table, edit the layout and look at the Query/Table=>Attach to menu - one of the tables at the top should be ticked, rather than one of the queries at the bottom (probably called "Join for <layoutname>").
If your layout uses a query, make a copy of the layout using the Layout/New Layout menu command, and choose the relevant table from Query=>Table=>Attach to menu.
Once the layout is attached to a table, you can set the clustering key by using the Query=>Table=>Edit=>Clustering key option, and set the sort order to the field(s) that identify each record (hopefully the same as the primary key, if your database is properly structured!).
Return to browse mode and import the CSV file - you should see that the field(s) you specified in the clustering key are shown in a darker grey, and if you select the 'Match sort key' option and make sure the correct fields from the CSV file are mapped onto the clustering key fields, it should all work as expected.
Note also that it may be advisable to clear the clustering key after performing the merge, especially if you have a number of secondary indexes (i.e. sorts) referring to the table in question, as each one of those needs to reference the clustering key of the table, and it's usually best if this is just left as the ID field, i.e. the entry order of the records.
To clear the clustering key, edit the layout again, then choose Query/Table=>Edit=>Clustering key from the menu, click on 'Clear', then click on OK and OK again to return. t
o browse mode. |
Q. |
Summaries |
A. |
How can I get totals of a field (i.e. summed data over all the records in a table)?
To make a summary of a field, you can simply create a footer area using the Arrange=>Main footer menu option, then drag the field you want to summarise from the body section into the footer.
Depending on the type of the field, you'll get a default summary type, e.g. for a numeric field you'd get a summary field with the formula:
Sum('OriginalFieldName')
Can I also group the records according to a certain field, and then have separate totals for each group? For example, can I group my butterflies by colour, and then find the average wingspan for each colour?
You can get a 'grouped' summary using a SQL query as follows:
Select 'GroupField', Sum('MyField')
From 'Table1'
Group By 'GroupField'
Having given the SQL query a name and saved it, create a new layout, press Ctrl-A then Delete to get rid of all the frames, and then choose Query/Table=>Attach to=>MySQLQueryName (or whatever you called it), and then bring the fields on from the fields menu on the toolbox. If you create a main header first and set the layout type to All Records, you'll find that the fields are arranged across the page just under the header, so you'll get a tabular result.
You can also sum the values within a subview by dragging a field from the subview onto the main record.
This will give a summary field with the formula:
Sum('MyField') For 'MainTableName'
which shows that there is a separate summary result for each record of 'MainTableName' (i.e. whichever table is the main one in the overall query for the layout containing the subview).
In this case Viewpoint effectively groups the summaries on the same field(s) that join the main table to the subview.
You can alter the formula of a summary field to use any of the following aggregate functions:
Sum Count Average Min Max
and you can use arbitrary expressions within and outside the aggregate function, e.g.
Sum('f1') / Max('f2'*'f3')
Note that the aggregate functions, which summarise a field over multiple records, shouldn't be confused with the non-aggregate versions of Sum(), Count(), Average(), Min() and Max(), which can act on normal fields within a record, eg:
Sum('f1','f2','f3','f4')
is equivalent to:
'f1'+'f2'+'f3'+'f4'
except that nulls are treated as zero, instead of causing the whole formula to come out null.
|
Q. |
Numbering records |
A. |
I want to print out from a Viewpoint database a list of names numbered in alphabetical order e.g. Adams, Bernard, Cook. Adding a name would automatically cause them to be renumbered. I suspect this must be possible since there is a counter in the program - can you advise?
It is not possible for the entries to be automatically renumbered when you add or alter a name, since the 'ID' value associated with each record is the entry order of the record, and does not change once you've entered the record. This is useful as a unique ID for each record, but no more.
However, you can write a script that gives each record a number as follows:
First add a numeric field, called (let's say) 'Number'.
Then add a script to a button on the background that says:
On ClickLeft
Renumber ( CurrentRecSet, "Number" )
// Subroutine that renumbers a recordset.
// The name of the field to renumber is passed in.
Sub Renumber ( recset as RecordSet, name as text )
Dim n as integer
Dim ok as boolean
Dim numfield as field
numfield = recset.Field(name)
n = 1
ok = recset.MoveFirst
while ok
numfield.setvalue ( n )
recset.Update
n = n + 1
ok = recset.MoveNext
endwhile
endsub
You can now just click on the 'Renumber' button on the layout background to renumber the records.
You can also do this with subviews in more complex layouts - just change CurrentRecSet to CurrentRecSet("Subviewname").
You can download an example file that does this by clicking here.
You can copy the script button into your own database by just dragging and dropping it across.
|
Q. |
Combing address fields |
A. |
I want to combine my existing single line address fields (address 1, Address 2 e.t.c.) into a single multi-line field, without leaving blank lines in the address.
You can use a simple formula field to combine the existing address fields as follows:
'Address1'+"\n"+'Address2'+"\n"+'Address3'+"\n"+'Address4'
The '\n' strings represent new lines within the text, and you just need to make the formula field's box big enough to show the required number of lines.
The problem with the above formula is that if any of the address fields is blank, you will get a blank line in your new address.
To solve this, modify the formula as follows:
(If 'Address1'<>"" Then 'Address1'+"\n" Else "") +
(If 'Address2'<>"" Then 'Address2'+"\n" Else "") +
(If 'Address3'<>"" Then 'Address3'+"\n" Else "") +
(If 'Address4'<>"" Then 'Address4'+"\n" Else "")
Now any blank address lines are completely omitted, so you don't even get a new line.
OK, now I have a formula field which I can use for an address label, but I still have to enter the addresses in the old multi-line fields. How can I get rid of the old address fields so I just enter addresses in the new multi-line field?
Now that you have a formula field with the new addresses in it, you first need to return to browse mode to check that they are correct.
Having done that, you can edit the layout again, select the new address field, click on the 'Text field' icon to change the field type to text, press Ctrl-Shift-G to edit the formula, press Ctrl-A then Delete to get rid of the formula, click OK, and then select the old address fields and press Ctrl-Delete to completely delete them.
If you now return to browse mode the new multi-line address field will contain the addresses, and you can modify or enter new data in this field in the usual way. |
Q. |
Updating linked file fields |
A. |
I want to transfer a database and contents to another driving/filing system but have found that the file reference is specific to that drive and system. Is there a way of modifying all references so I can get it to look at a new drive? I will need to change the reference to an alternative filing system - is this possible or do all the references need to be changed by hand?
Yes, it certainly is possible to do this using a script.
There are two main functions you need:
FileName() // returns the name of a linked file
FileLink() // creates a link to a file from a name
The following script replaces all occurrences of a given string within file links in a given field of a given table with another string:
ReplaceLinks("Table1","MyFileField","CDNET::$.pictures","NEWDISK::$.Pictures")
assuming:
- Table1 is the name of the table (this is the default in a flat file)
- MyFileField is the name of your field in this table
- CDNET is the old disk name
- NEWDISK is the new disk name
In order for this to work, you first need to copy and paste the following script into the global scripts of your database. To do this, edit the layout and choose Edit Scripts from the File menu.
Sub ReplaceLinks (tname as text, fname as text, old as text, new as text)
Dim r as recordset, f as field, link as text
r = CurrentDB.QueryDef(tname).OpenRecordset
f = r.Field(fname)
Dim ok as boolean
ok = r.MoveFirst
While ok
link = FileName(f.GetValue)
if link <> null then
link = replace(link,old,new)
f.SetValue(FileLink(link))
r.Update
endif
ok = r.MoveNext
EndWhile
EndSub
Having done this, you can create a background frame somewhere on your main layout (using the frame tool in the toolbox, drag out a rectangle to create the frame, then click the text tool and click in the frame to enter a label (e.g. 'Convert links')).
Then select your background frame button and press Ctrl-T and enter the following script:
On ClickLeft
ReplaceLinks("Table1","MyFileField","CDNET::$.pictures","NEWDISC::$.Pictures")
You'll need to alter the table and field names as appropriate, of course.
As an example, if your pictures moved from an absolute location on a separate drive to a directory next to the database, you could use:
On ClickLeft
ReplaceLinks("Table1","MyFileField","CDNET::$.pictures","Pictures") |
|
|
|