How do I make entry all caps

Creating and using forms

How do I make entry all caps

Postby mktork » Thu Feb 23, 2012 3:48 am

Is it possible to make the data entered into my forms be all capital?
Last edited by mktork on Wed Feb 29, 2012 12:05 am, edited 3 times in total.
openoffice 3.3 runs on microsoft xp
mktork
 
Posts: 24
Joined: Sat Oct 01, 2011 9:41 pm

Re: How do I make entry all caps

Postby DACM » Thu Feb 23, 2012 9:24 am

mktork wrote:Is it possible to make the data entered into my forms be all capital?

 Edit: See Villeroy's post below...
Villeroy wrote:Simply use a pattern field.
 

It is possible, with a macro...

Code: Select all   Expand viewCollapse view
Sub UPPER_case (oEvent As Object) 'Text Box > Events > When Losing Focus
   oTextBox = oEvent.Source.Model
   sText = Ucase(oTextBox.Text)
   oTextBox.setString(sText) 'same effect as .BoundField.updateString() below
'   oTextBox.BoundField.updateString(sText) 'same effect as .setString() above

'   oForm = oTextBox.Parent 'these 3 lines combined will immediately save the record...
'   oForm(oTextBox.Name).commit()
'   IF oForm.isnew THEN oForm.insertRow() ELSE oForm.updateRow()
End Sub
Last edited by DACM on Wed Feb 29, 2012 7:12 pm, edited 1 time in total.
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
User avatar
DACM
Volunteer
 
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: How do I make entry all caps

Postby mktork » Tue Feb 28, 2012 11:58 pm

Thank you DACM. I'm just starting to learn macros so I have a few newbie questions.
First, which language is that? JAVA?
Second,do you know any good tutorials for learning that language?

Thank you for any and all help given.

Mktork
openoffice 3.3 runs on microsoft xp
mktork
 
Posts: 24
Joined: Sat Oct 01, 2011 9:41 pm

Re: How do I make entry all caps

Postby rudolfo » Wed Feb 29, 2012 12:39 am

The language that is used in the above macro is OpenOffice Basic. But actually it is not really relevant, there is only one line that is specific for Basic and this is the Ucase function.
And if someone looks at the heavy use of periods you can easily think it looks like Java. But the reason for this is not the scripting language, but the fact that macros work with so called UNO objects (if I simplify this a little bit each OpenOffice application Writer, Calc ... can be seen as UNO objects that were glewed together in a clever way) and that these UNO objects expose an Application Programming Interface (API). Because we are looking at objects a notation as oEvent.Source.Model or oTextBox.BoundField.updateString() is pretty common: Select an object as a descendant of a object hierachy and call a method of that object.

So the good news is: If you already know a programming language it is likely that you can use it for OpenOffice Macro programming: Java, C#, Javascript, Python, Basic (and even VisualBasic (Script) through something that is called COM-Automation bridge). The drawback is that the API needs to "please" all languages and this makes some parts in some of the languages more complicated as it would normally need to be. Or I can put it the other way round: It is the API, that you have to learn (70 or 80 percent) not the programming language that you use for scripting.

The Macro Forum has a sticky thread at the top of all the posts Need thorough documentation of OOo BASIC objects, which has several pointers to documentation. If it comes to macro programming in OOo Base I always recommend Roberto Benitez' page on Base Programming, particularly the last two pdf documents listed on that page.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
rudolfo
Volunteer
 
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: How do I make entry all caps

Postby Villeroy » Wed Feb 29, 2012 9:43 am

Simply use a pattern field.

F1 Help wrote:Edit mask
By specifying the character code in pattern fields, you can determine what the user can enter in the pattern field.
The length of the edit mask determines the number of the possible input positions. If the user enters characters that do not correspond to the edit mask, the input is rejected when the user leaves the field. You can enter the following characters to define the edit mask:
Character
Meaning
L
A text constant. This position cannot be edited. The character is displayed at the corresponding position of the Literal Mask.
a
The characters a-z and A-Z can be entered. Capital characters are not converted to lowercase characters.
A
The characters A-Z can be entered. If a lowercase letter is entered, it is automatically converted to a capital letter
c
The characters a-z, A-Z, and 0-9 can be entered. Capital characters are not converted to lowercase characters.
C
The characters A-Z and 0-9 can be entered. If a lowercase letter is entered, it is automatically converted to a capital letter
N
Only the characters 0-9 can be entered.
x
All printable characters can be entered.
X
All printable characters can be entered. If a lowercase letter is used, it is automatically converted to a capital letter.

For the literal mask "__.__.2000", for example, define the "NNLNNLLLLL" edit mask so that the user can only enter four digits when entering a date.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29699
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How do I make entry all caps

Postby DACM » Wed Feb 29, 2012 6:36 pm

Villeroy wrote:Simply use a pattern field.

F1 Help wrote:Edit mask
A
The characters A-Z can be entered. If a lowercase letter is entered, it is automatically converted to a capital letter
C
The characters A-Z and 0-9 can be entered. If a lowercase letter is entered, it is automatically converted to a capital letter

I did not know that. Thanks Villeroy!
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
User avatar
DACM
Volunteer
 
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: How do I make entry all caps

Postby Villeroy » Wed Feb 29, 2012 6:44 pm

You're welcome ;)
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29699
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Forms

Who is online

Users browsing this forum: No registered users and 6 guests