OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

TextBox connected to database

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Gianluca Bardi
General User
General User


Joined: 08 Sep 2003
Posts: 9
Location: Via delle Panche 181 I-50141 Firenze - Italy

PostPosted: Tue Dec 09, 2003 9:49 pm    Post subject: TextBox connected to database Reply with quote

I have a form connected to a database table. In the form there is a textbox in which I need to write the content by a macro by the following instruction:
oCtl2.Text = "whateveryoulike"
Actually after running the macro, the textbox in the form shows "whateveryoulike". The problem is that even if I try to save the situation into the database table by clicking the SAVE icon no effect in the table is observed. The content of the field bound to the textbox doesn't contain "whateveryoulike" but remains unchanged as it was before running the macro.
_________________
Gianluca Bardi
Back to top
View user's profile Send private message
dfrench
Moderator
Moderator


Joined: 03 Mar 2003
Posts: 1605
Location: Wellington, New Zealand

PostPosted: Wed Dec 10, 2003 5:48 am    Post subject: Reply with quote

The control needs to have the focus before it detects the change and enables the 'save' of the changed data. Thanks to thingkcp and http://www.oooforum.org/forum/viewtopic.php?t=1046&highlight=mysql
the following code takes you to the point at which the change can be saved to the database



Code:
Sub Main
oController = ThisComponent.CurrentController
oForm = ThisComponent.drawpage.forms.GetByName("Standard")
rem This assumes that the form has the default name "Standard"
cControl = oForm.GetByName("TextBox")
rem this is the control model
oControlView = oController.GetControl(cControl)
rem this is the control view - the object you want to work with
oControlView.SetFocus  'sets the focus
 
cControl.Text = "anything"  'changes the text in the box
' now you can explicitly save (see change in save icon on navigation bar)

End Sub
Back to top
View user's profile Send private message
g.bardi
Guest





PostPosted: Wed Dec 10, 2003 11:46 pm    Post subject: TextBox connected to database Reply with quote

It works perfectly, thanks a lot.
Back to top
Gabriel123
Newbie
Newbie


Joined: 14 Jan 2008
Posts: 2

PostPosted: Thu Jan 17, 2008 7:33 am    Post subject: get the focus Reply with quote

This is a very nice snippet...I have a form with about 20 fields that are macro filled. How can i get the focus on each of them to save them into the table?

Any Way? Thanks in advance!
Back to top
View user's profile Send private message
Evgenych
General User
General User


Joined: 03 Jan 2008
Posts: 9

PostPosted: Sun Jan 27, 2008 6:52 am    Post subject: Reply with quote

I use commit() method of control, when change controls programmaticaly

sub onCheckbox ()
oForm = ThisComponent.DrawPage.Forms.getByName("MainForm")
oCheckBox = oForm.GetByName("CheckBox")
oTxt = oForm.GetByName("txtNaryad_zakaz")

if oCheckBox.CurrentValue = 1 then
oTxt.Value = 1
oTxt.commit()
else
oTxt.Value = nul
oTxt.commit()
end if

end sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group