Setting the Text value of a database form ctl

The Application Programming Interface and the OASIS Open Document Format

Setting the Text value of a database form ctl

Postby slw » Sun Nov 23, 2008 5:58 am

I am trying to insert the system time into a text field of a database form with the following code. It hangs up on the "Form =" line, but I have been unable to figure out why or to work around it. Any help?

Sub Main

Dim Start as Date
Start = Now
Dim Doc As Object
Dim Form As Object
Dim Ctl As Object
Doc = StarDesktop.CurrentComponent
Form = Doc.DrawPage.Forms.GetByIndex(0)
Ctl = Doc.getByName("StartTime")

Ctl.Text = Start

End Sub
OOo 3.0.X on Ms Windows XP
slw
 
Posts: 2
Joined: Sun Nov 23, 2008 5:51 am

Re: Setting the Text value of a database form ctl

Postby probe1 » Fri Nov 28, 2008 7:20 am

Welcome to the forum.

Does it just "hung" - or do you get an error message?

StarDesktop.getCurrentComponent() will get you an object of the Basic-IDE, if you run your code from there....

For the (maybe) underlying problem: maybe this could help...?
Cheers
Winfried

DateTime2 extension: insert date, time or timestamp, formatted to your needs
User avatar
probe1
Volunteer
 
Posts: 277
Joined: Mon Oct 08, 2007 1:34 am
Location: Chonburi Thailand

Re: Setting the Text value of a database form ctl

Postby slw » Sat Nov 29, 2008 10:59 pm

Thanks for your reply. What I am trying to do is create a timeslip. When I click the start/stop button once, I want the system time and date to appear in the "StartTime" formatted field (not connected to any table). When I click a second time, I want the system time and date to appear in the "StopTime" formatted field (also not connected to a table). I then have a third field (connected to a table) that I want to total the elapsed time based on the first two fields. In Access I am able to do all this fairly easiliy with VB because it is easy to determine fully qualified control names by navigating through a tree. I don't understand how to reference controls in ooBasic.

Thanks again,
--slw
OOo 3.0.X on Ms Windows XP
slw
 
Posts: 2
Joined: Sun Nov 23, 2008 5:51 am


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest