Submit a Form Field

Creating and using forms
Post Reply
User avatar
Ant
Posts: 21
Joined: Wed Oct 08, 2008 5:22 am

Submit a Form Field

Post by Ant »

I've written code to place values into a field in a form.

The problem is when I move to the next record it doesn't save the value to the database.
But if I mouse click in the target field, then into another field, it does save the value.

It seems my code can display a value in a field, but the database doesn't know about it unless I actually click into that field.

Is there a method I can use to update a field?

Code I'm using:

Code: Select all

Sub PasteToQSamt
  Dim oThisPage
  Dim oShape
  Dim i as integer
  Dim sControlShape
  dim oName as string 
  dim CVAamt as double

  sControlShape = "com.sun.star.drawing.ControlShape"
  oThisPage = ThisComponent.getDrawPage()

  'Loop through all the shapes  
  For i = 0 To oThisPage.getCount() - 1
    oShape = oThispage.getByIndex(i)
    If oShape.supportsService(sControlShape) Then
      oName = oShape.Control.Name

  'Get data from calc Form fields
       if oName = "calcFullAmount" then
          CVAamt = oShape.control.text
'         CVAamt = oShape.control.effectivevalue  'this only works if format displaying in field
      end if 
      
     End If   
   Next  'end get data loop

  'Loop through all the shapes  
  For i = 0 To oThisPage.getCount() - 1
     oShape = oThispage.getByIndex(i)
    If oShape.supportsService(sControlShape) Then   
       oName = oShape.Control.Name

  'Place answers into Form Fields
       if oName = "QSamt" then
          oShape.control.text = CVAamt
''!!!!!!   UPDATE FORM FIELD HERE?   !!!!!!!
      end if    
      
    End If
  Next  'end put data loop
End Sub
Post Reply