Proper / Title case in Base fields

Discuss the database features
Post Reply
a3dvm
Posts: 2
Joined: Mon Jan 07, 2008 2:55 pm

Proper / Title case in Base fields

Post by a3dvm »

Hi
Proper Case - Base Form Fields:
I've had an on going problem trying to convert fields to proper / title case.
I've spent days scouring the web, forums, and tried all sorts.
I've tried one suggestion from Kabing to use a Pattern Field, which works fine - but now I realise that it only capitalises the first word in a string, not all words as I require.
I think the answer must be a macro - but I'm finding a problem with that.

The inbuilt macro 'Capitalise.bsh' only appears to work on text items when they are placed on the form. If attached to a form event - they will work automatically as I want.
But when the same macro is attached to a field event - nothing in the field changes. Even selecting the field and running the macro manually does nothing.

All the BeanShell macros appear to work - but only on text placed on the form itself macros - not in fields.

Am I missing something obvious here? Is there something I need to do or setup to make a macro trigger from an event based on a field, and change that fields contents. (say, AfterUpdating or WhenLosingFocus)

I take it it is possible to run macros on database field text?
I have located and added to MyMacros various macros found on the web, and they either fail on saving, (invalid language?) or just don't work from an event.

Any help vastly appreciated - it's driving me nuts!
Den
wurzel
Volunteer
Posts: 145
Joined: Sun Dec 09, 2007 10:39 am

Re: Proper / Title case in Base fields

Post by wurzel »

a3dvm wrote: I think the answer must be a macro - but I'm finding a problem with that.

The inbuilt macro 'Capitalise.bsh' only appears to work on text items when they are placed on the form. If attached to a form event - they will work automatically as I want.
But when the same macro is attached to a field event - nothing in the field changes. Even selecting the field and running the macro manually does nothing.
Since I haven't looked at the beanshell macro, I'm assuming that only works on text elements that are defined as such in the form, i.e. the Writer document. The text data in your fields is database data, not form content. The fields that appear on your form are container elements (literally controls) for the underlying elements, be they text, numeric, binary, boolean, whatever.
a3dvm wrote: Am I missing something obvious here? Is there something I need to do or setup to make a macro trigger from an event based on a field, and change that fields contents. (say, AfterUpdating or WhenLosingFocus)

I take it it is possible to run macros on database field text?
I have located and added to MyMacros various macros found on the web, and they either fail on saving, (invalid language?) or just don't work from an event.
Den
In order for macros to run on the data itself, you have to tell the macro which data to retrieve and change, use OOoBasic string methods to capitalise the text and then write that change back to the database. You could do this for example by :

- creating and opening a connection to your db source
- identifying all of the fields containing text data
- retrieving the text data from the list of fields for a given row (i.e. creating a rowset)
- converting that text in each rowset into capitalised form using inbuilt string functions
- rewriting the modified data to the underlying database
- reloading the form to display the modified data

Bear in mind that I'm not a Basic programmer as such, so there might be easier ways of doing what I suggested above.

Alex
a3dvm
Posts: 2
Joined: Mon Jan 07, 2008 2:55 pm

Re: Proper / Title case in Base fields

Post by a3dvm »

Thanks Alex
I'll give your suggestion a try.
Den
Post Reply