Archive for the ‘Scan and Shred’ Category

When an image field is unexpectedly read-only

18 February 2010

From time to time the following thing happens to people:

  1. They add an image field to an existing database.
  2. They try to add an image to the database.
  3. Cardbox reports that the image field is read-only.

Understandably, this is rather puzzling. It only happens with databases that were created with older versions of Cardbox. The quick cure is to rebuild the database with Tools > Management > Rebuild > Database. This Knowledge Base page gives a detailed explanation.

Advertisements

Partially duplicating a record

1 May 2009

In a scan-and-shred type of database, I often find myself wanting to duplicate everything except the image or object field. For instance, I may be filing bank statements, where all the details are the same as last time except for the date and the scanned image itself. Here’s a macro that does this.

Set rec=ActiveRecord
AddRecord
Set recNew=ActiveRecord
For Each fld In rec.Fields
 If fld.Definition.Type=cbxFieldTypeText Then
  recNew.Fields(fld.Definition.Name)=fld
  End If
 Next

I save this macro in the “This Database” section, under the name “Partial Duplicate”. Then, to make things easier for myself, I edit the native format of the database, do Tools > Keyboard, and associate Ctrl+D with playing the “Partial Duplicate” macro. Since Ctrl+D is normally Cardbox’s own shortcut for File > Duplicate Record, this means that I don’t have to change my typing habits.

One refinement: one of my fields, called NUMBER, has an auto-numbering validator in it. If I duplicate that field, the new record will have the same serial number as the old – which I don’t want. So I add the following line at the end of the macro:

recNew.Fields("NUMBER")=""

Now the field will be blanked out, and Cardbox will number it automatically when I save the record.