Home

Macros and Programming

 

CardboxForumsMacros and Programming > "Edit a field using Extra Text"

Edit a field using Extra Text

Small macro to edit fields full-screen.

Current user: [none]
Register / Log In · Help

Posted By Post

Charles Welling

1-Nov-2009 18:50

For anyone who would like to edit fields full-screen, the following macro might be useful.
It uses the Extra Text field as a temporary field for editing.
To be able to use it, the database must have the Extra Text field activated, and it should not be used for anything else.
I've chosen to have the Extra Text NOT visible when the database is opened, so users will not even see (or know) that it exists. I've assigned F6 to the macro. It should only work when the user is editing.

What the macro does, is very simple.
If the user is in the main format, the macro remembers the active field.
It puts the content of the active field into the Extra Text and then it makes the Extra Text visible. The user has a whole screen to edit the text. You can even use TAB's.
When the user presses F6 again, the second part of the macro is executed. The cursor returns to the previously active field in the main format, and the edited text is copied to that field.
The Extra Text is emptied.

Here's the macro:

if ExtraText = 0 then
scrap(1) = ActiveFieldname
Fields("**") = ActiveField
ExtraText = 1
else
GotoField scrap(1)
ActiveField = Fields("**")
Fields("**") = ""
end if

Charles Welling

1-Nov-2009 19:15

And as a PS:

Don't use this on image or object fields. I suddenly realised that this can inadvertently happen. Please use the following improved macro that eliminates this possibility.

if ActiveWindow.FieldDefinitions.Item(ActiveFieldname).Type = cbxFieldTypeText then

if ExtraText = 0 then
scrap(1) = ActiveFieldname
Fields("**") = ActiveField
ExtraText = 1
else
GotoField scrap(1)
ActiveField = Fields("**")
Fields("**") = ""
end if

else
MsgBox "This is not a text field."
end if

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home