Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


Sorry Bill,

I could have added a bit more explanation regarding the code I sent you.
Basically, it looks at the form object to see what sort of control you want
to store a value in, and then chooses either the Date code or the other
alternative for all other control types.

I should have added that I am running an H2 Database on Windows 7.  I have
found in the past that my code doesn't always translate to other
Databases/Operating Systems, but in this case I thought the code would
probably be Database/System independent.

So, I would suggest that you try running the code first to see if it works
for you.  If it does, then I could help you to understand how it ticks
should there be any parts that were unclear to you.  If it doesn't work,
then you would not have spent time on something that you can't use.

My 2c worth!

Noel
--
Noel Lodge
lodgemn@gmail.com

On 5 January 2015 at 13:18, Bill Gradwohl <bill@ycc.com> wrote:

Thank you for the information.
I'll have to deconstruct the code to understand what's going on, as I
don't like black boxes. That's probably going to take me a while.

Many thanks.

On Sun, Jan 4, 2015 at 7:59 PM, Marion & Noel Lodge <lodgemn@gmail.com>
wrote:

Hi Bill,

I also encountered this problem.  It turns out that you need to update the
Control's bound field.  Below is a modified version of a Macro I use. To
update most Controls is fairly straightforward, but a Date Control is a
bit
more complicated. As you can see, you pass the Control Name, the new Value
and the Form object to the Macro.

In your case I think if you called -
  libUpdateControlValue("Date", "2015-01-04", DateField)
you will get the result you want.

Sub libUpdateControlValue(sControlName AS String, sNewValue AS String,
oControl AS Object)

    Dim DateStruct        AS new "com.sun.star.util.Date"
    Dim sDateValue         AS String
    Dim sControlType    AS String

    sControlType = oControl.DataFieldProperty

    if Instr(1,"Text,EffectiveValue,SelectedItems",sControlType) > 0 then
            oControl.boundfield.updateString(sNewValue)    ' Sets the new
value in the boundfield Object
    End if

   if sControlType = "Date" then
        sDateValue = sNewValue    ' to prevent sNewValue being changed!
        if len(sDateValue) = 10 then     ' = yyyy-mm-dd
            sDateValue = left(sDateValue,4) + mid(sDateValue,6,2) +
right(sDateValue,2)    ' = yyyymmdd
        End if
        DateStruct.year  = left(sDateValue,4)
        DateStruct.month = mid(sDateValue,5,2)
        DateStruct.day      = mid(sDateValue,7,2)
        oControl.boundfield.updateDate(DateStruct)        ' Sets the new
value in the boundfield Object
    End if
End Sub

​Let me know​ if you have any problems.

​Noel​
--
Noel Lodge
lodgemn@gmail.com

On 5 January 2015 at 06:39, Bill Gradwohl <bill@ycc.com> wrote:

Please correct me if I'm wrong, and if there's a better place to ask,
let
me know.

It is my understanding (experimentally verified) that the PriorToReset
event will fire when a new database row is produced for data entry.
Inside
this event, I can use the passed in event object to get the Form and
from
the form get at the elements of the form.

I named my sub the same as the event it relates to.

Sub PriorToReset(event)
dim Form
dim DateField
Form=event.source
DateField = Form.getByName("Date")

Now I can drop a date into the "Date" field via :
DateField.setPropertyValue("Text",
​"01/04/2015"​
)
​
That date shows up on the screen as though I had keyed it in by hand.
Great
so far.


Once I fill out the remaining fields manually, and an attempt is made to
send the data to the database, an error shows up asking to fill in the
mandatory "Date" field. I'm looking at it filled in exactly as I want
it,
but somehow the system thinks it's not filled in. If I focus the date
field
and backspace over the last digit (5) and then re enter 5 and hit enter,
and then attempt to save the record, it works. Why?

​Why can I see the date field filled in exactly as I want it, but
somehow
the system thinks the field is empty or somehow invalid until I touch
the
field and tinker with its last digit. If I set the last digit to 9, for
example, a database row is stored with 01/04/2019 in it as expected.

--
Bill Gradwohl

--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems?
http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more:
http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be
deleted


--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems?
http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be
deleted




--
Bill Gradwohl


-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.