Simulating tabs in a form.

Creating and using forms

Re: Simulating tabs in a form.

Postby Anne » Sun Jul 06, 2008 3:53 am

Quazzie:
I'm not exactly sure how to post a database to the forum, but if I could figure that out, I could post it here. The problem I described only happens in the situation where I am in the middle of inserting a record on the insert form, then switch to the other form and do a RefreshForm function there(using the pre-defined action for a Refresh button). The form on which I am doing a RefreshForm has a main datasheet form attached to a query, and a subform attached to the same table as the Insert form is attached to. It seems that when the RefreshForm happens on the datasheet form, the database saves the record I'm working on in the Insert form, and because it has just created a new primary key, it updates that key and redisplays the ID field on the Insert form. Because the insert form is currently hidden, the lone primary key field pops up in the middle of my other form.

Actually, it isn't just the redisplay of the field that is the problem here. I don't think the database should be saving a record on the Insert form when I am refreshing a different form, even though both are attached to the same table. I didn't check to see if the same problem happens if both forms are running in separate form windows without the tabbed menu.

I wasn't sure what you meant when you said to check what the controls were anchored to. Could you explain that a bit? (I'm a relatively new oo base user - learning slowly, but still have lots to learn)

If you are unable to simulate the same behaviour, I can post my database. Where can I find out how to do that?
Anne
 
Posts: 25
Joined: Fri Feb 01, 2008 2:22 am

Re: Simulating tabs in a form.

Postby Anne » Sun Jul 06, 2008 4:36 am

OK. I just tried to upload the database & OXT file as attachments (using the Upload Attachment tab), but the DB was too large, and the .oxt extension was not allowed as a file type to upload...
Are there any other options for getting this database on the forum?
Anne
 
Posts: 25
Joined: Fri Feb 01, 2008 2:22 am

Re: Simulating tabs in a form.

Postby Anne » Sun Jul 06, 2008 5:17 am

Because I could not attach my entire database, I have attached the writer document that contains all my forms, controls, etc. I have also included the macro library below as inline code. The 2 forms that are causing the problem are in the ViewResources section, and the Catalogue section. When I tab to the Catalogue section, and press the New button to insert a record, then, before saving the record, tab to ViewResources and press Refresh, the primary key field from the Catalogue section pops up on the screen in the middle of the ViewResources form. Let me know if you need any more details. Also, please realize this is a "work in progress", created mostly from ideas gleaned from the oo forums, not a finished application. Any suggestions are most welcome .

Code: Select all   Expand viewCollapse view
function AddNewPatron(oEvent as object)
dim oDialog
dim oModel
dim NameCtrl
dim oDataForm
dim newName as string
'   BasicLibraries.LoadLibrary("new_library")
' make sure the dialog library is loaded
   DialogLibraries.LoadLibrary("new_library")
   oDialog = CreateUnoDialog( DialogLibraries.new_library.DlgNewPatron  )   
   oModel = oDialog.Model
    NameCtrl = oDialog.getControl("NameFld")
    newName = ""
    NameCtrl.Text = newName

    if oDialog.execute() = com.sun.star.ui.dialogs.ExecutableDialogResults.OK then
      ' user pressed OK.  If there is a name in the field, add it to the database
      if NameCtrl.Text <> "" then
        ' add the value to the database
        oStatement = oEvent.Source.Model.Parent.ActiveConnection.CreateStatement
       sqlStr = "INSERT INTO ""Patron""(""Name"") VALUES ('"  & NameCtrl.Text & "')"
       oStatement.executeUpdate( sqlStr )
       newName = NameCtrl.Text
     end if
end if
oDialog.dispose()
AddNewPatron = NewName
end function

' called from a button on the check out screen that allows the user to add a new patron while in the process
' of checking out books.  If a new patron gets added, the patron list box gets updated.
sub Onclick_btnNewCheckOutPatron( oEvent as object)
    dim newPatron as string
    newPatron = AddNewPatron(oEvent)
    if newPatron <> "" then
       oEvent.Source.Model.Parent.getByName("CheckOut_Grid").getByName("NameListBox").refresh()
    end if
end sub   
' ---------------------------------------------------------------------------------------------------------



REM to be run on loading the main form of the application (ie. at start-up) 
REM This routine will set the tab control to show the check out form to the user when the program is started.
Sub onLoadEvent(oEvent as object)
   Dim oButton as object
   Dim oForm as object
 
   oForm = ThisComponent.Drawpage.Forms.getByName("MenuBar")
 
   oButton = oForm.getByName("CheckOut")
   ToggleTabControls(oButton)
   ' hide the loading screen   
   ThisComponent.TextSections.getByName("LoadingScreen").IsVisible=FALSE 
End Sub

' make all sections in the current document visible
Sub RestoreSectionVisibility()
   dim i
   dim Sections as object
   Sections = ThisComponent.TextSections.GetElementNames()
   for I=0 to UBound(Sections)
       ThisComponent.TextSections.getByName(Sections(i)).IsVisible=TRUE
   next i       
end sub
 
' when the menu screen is exited, turn the forms all back on so they are easier to edit later, and
' so that the loading screen will appear the next time the database is accessed.
Sub onExit()
    RestoreSectionVisibility()
end sub   


sub closeForm
   ' changed 01/21/06 ATJ
   ' disposing of a variable to a form def
   ' no longer closes the form in
   ' 2.0.1
   thisComponent.CurrentController.Frame.Close( false )
   'oActiveProjectForm.dispose
end sub     

sub Onclick_btnProcessReturns( oEvent as object )
   dim oDateCtrl
   dim oStatement
   dim sqlStr
   dim dtStr
   
   oDateCtrl = oEvent.Source.Model.Parent.getByName( "dtReturnDate" )
   if oDateCtrl.Text = "" then
      msgBox("You must select a return date")
   else      
      oStatement = oEvent.Source.Model.Parent.ActiveConnection.CreateStatement
      dtStr = cstr( oDateCtrl.Date )
      dtStr = left( dtStr, 4 ) & "-" & mid( dtstr, 5, 2 ) & "-" & right( dtStr, 2 )
      sqlStr = "UPDATE ""CheckOut"" SET ""DateIn"" = " & "'" & dtStr & "'"
      sqlStr = sqlStr & " WHERE ""CheckOut"".""BookID"" IN ( SELECT ""BookID"" FROM ""tmp_returns"" ) AND ""CheckOut"".""DateIn"" IS NULL"
      oStatement.executeUpdate( sqlStr )
      sqlStr = "DELETE FROM ""tmp_returns"""
      oStatement.executeUpdate( sqlStr )
      oEvent.Source.Model.Parent.Reload
      oDateCtrl.Text = ""
   end if
end sub



sub Onclick_btnProcessCheckOut( oEvent as object )
   dim oDateCtrl
   dim oStatement
   dim sqlStr
   dim dtStr
'      oDateCtrl = oEvent.Source.Model.Parent.Parent.getByName("TmpCheckOut").getByName( "dtCheckOutDate" )
   oDateCtrl = oEvent.Source.Model.Parent.getByName( "dtCheckOutDate" )
   dtStr = cstr(oDateCtrl.Text)
   
   
   if    oDateCtrl.Text = ""  then
      msgBox("You must select a Check Out Date")
   else
   
      oStatement = oEvent.Source.Model.Parent.ActiveConnection.CreateStatement
      dtStr = cstr( oDateCtrl.Date )
      dtStr = left( dtStr, 4 ) & "-" & mid( dtstr, 5, 2 ) & "-" & right( dtStr, 2 )
      sqlStr = "UPDATE ""CheckOut"" SET ""DateIn"" = " & "'" & dtStr & "'"
      sqlStr = sqlStr & " WHERE ""CheckOut"".""BookID"" IN ( SELECT ""BookID"" FROM ""tmp_checkout"" ) AND ""CheckOut"".""DateIn"" IS NULL"
       msgbox(sqlstr)
      oStatement.executeUpdate( sqlStr )
      sqlStr = "INSERT INTO ""CheckOut"" (""BookID"",""PatronID"") SELECT ""BookID"", ""PatronID"" FROM ""tmp_checkout"""
        oStatement.executeUpdate( sqlStr )
        sqlStr = "UPDATE ""CheckOut"" SET ""DateOut"" = " & "'" & dtStr & "'"
      sqlStr = sqlStr & " WHERE ""CheckOut"".""BookID"" IN ( SELECT ""BookID"" FROM ""tmp_checkout"" ) AND ""CheckOut"".""DateOut"" IS NULL"
      oStatement.executeUpdate( sqlStr )
      sqlStr = "DELETE FROM ""tmp_checkout"""
      oStatement.executeUpdate( sqlStr )
      oEvent.Source.Model.Parent.Reload
         oDateCtrl.Text = ""
   end if
end sub






' this macro was recorded to bring up the search dialog box on a screen, and add a filter based on what is in the
' dialog box
sub GetAndApplyFilter(oEvent as object,FldName as string)

dim oFilter as object
dim oFormCtl as object

dim oDialog
dim oModel
dim NameCtrl

dim searchString as string
'   BasicLibraries.LoadLibrary("new_library")
' make sure the dialog library is loaded
   DialogLibraries.LoadLibrary("new_library")
   oDialog = CreateUnoDialog( DialogLibraries.new_library.DlgSearchResource  )   
   oModel = oDialog.Model
    NameCtrl = oDialog.getControl("SearchString")
 
    NameCtrl.Text = ""

    if oDialog.execute() = com.sun.star.ui.dialogs.ExecutableDialogResults.OK then
      ' user pressed OK.  If there is a name in the field, add it to the database
     
      oFormCtl = oEvent.Source.Model.Parent
     
      if NameCtrl.Text <> "" then
       
         
         'oFilter = oFormCtl.getByName("StateSearchListBox")
         searchString = NameCtrl.Text

         oFormCtl.Filter = "UPPER(" & FldName & ") LIKE UPPER('%" & searchString & "%')"
         oFormCtl.ApplyFilter = True
       
      else
         oFormCtl.ApplyFilter = False
      end if

      oFormCtl.Reload
       
    end if
oDialog.dispose()
 
end sub


sub OnClick_PerformSearch(oEvent as object)

dim oFilter as object
dim oFormCtl as object
dim sTitle as string
dim searchString as string
      GetAndApplyFilter(oEvent, oEvent.Source.Model.Name)

end sub



sub Onclick_RemoveFilter(oEvent as object)
dim oFormCtl as object
oFormCtl = oEvent.Source.Model.Parent
oFormCtl.Filter = ""
oFormCtl.ApplyFilter = FALSE
oFormCtl.Reload()
end sub

sub SyncronizeSubForms(oEvent as object)
 
    oEvent.source.model.commit() Rem... commits the value from the combobox into its bound field
    oEvent.Source.Model.Parent.GetByName("DetailList").reload()  rem this will reload the subform data.
End sub
Sub OnClick_MainTab(Event As Object)
   Dim oButton as object
   oButton = Event.Source.Model
   ToggleTabControls(oButton)
end sub


'generic tab control button function: goes through all the sections in the document, and if the name of the button
' matches a document section, we make that section visible.
' If there are other controls on the form with names that match section names, we make those sections invisible.
' IMPORTANT: all toggle buttons MUST have names that match the section names in the document where the form
' exists that you want displayed when the button is pressed.

Sub ToggleTabControls(oButton as object)
     
    Dim I As Integer
    dim j as integer
    Dim VisibleSection as String
    Dim sections as object
    dim ElementNames as object
   
     
   Sections = ThisComponent.TextSections.GetElementNames()
   ButtonNames = oButton.Parent.GetElementNames()
   
  'Go through every section in the document.  If the name of the section you want to turn on is the same as
  ' the document section you found, set the document section to be visible.  Otherwise, if there is a button
  ' attached to this document section, set the button off, and the document section invisible.
   VisibleSection = ""
   For I=0 to UBound(Sections)
 
    ' if the button name matches the section name, make that section visible 
    If oButton.Name=ThisComponent.TextSections.getByName(Sections(i)).Name Then
         
         VisibleSection=Sections(i)
    else
         
         for j=0 to UBound(ButtonNames)
              if ButtonNames(j) = Sections(i) then 
                   ThisComponent.TextSections.getByName(Sections(I)).IsVisible=FALSE
                   oButton.Parent.GetByName(Sections(I)).state = FALSE
                   j = UBound(ButtonNames)
              end if
         next j         
     End If   
         
   Next I

if (VisibleSection <> "") then
  oButton.state = PressedState 
  ThisComponent.TextSections.getByName(VisibleSection).IsVisible=TRUE
end if
End Sub


Attachments
Library Application Form.odt
This is the main form document for my db application
(21 KiB) Downloaded 436 times
Anne
 
Posts: 25
Joined: Fri Feb 01, 2008 2:22 am

Re: Simulating tabs in a form.

Postby QuazzieEvil » Mon Jul 07, 2008 6:11 pm

Well, got as far as duplicating your situation. Is your primary key an Auto-Incrementing Column? It did not happen for me for a non auto-incrementing column.

Since the primary key column is required when entering data, the first form that 'saves' the new row must supply a value. In this case, it would call the IDENTITY function to supply that value. If that value changes, then it must be updated on the form control. and in this case it seems to set the focus to it, which causes it to become visible. But it seems you already figured this out. the question is how to fix it. The quickest solution that comes to mind is to save the form (for new entries) when you change tabs. If the first tab is your default tab, it will save it on the first tab change (out of first tab) and the problem will go away.

to save the form programmatically try the following.

Code: Select all   Expand viewCollapse view
If Form.IsNew Then
   Form.insertRow()
Else
  Form.updateRow()
End If


WARNING: This will only work if either the primary key is the only required field, or the other required fields are on the same tab. If you have required fields on other tabs which you have not yet accessed/modified, the insert/update attempt will fail.
QuazzieEvil
Volunteer
 
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: Simulating tabs in a form.

Postby Anne » Mon Jul 07, 2008 6:41 pm

Thanks for the response, QuazzieEvil. I think your proposed solution would solve the problem of the field suddenly appearing where it isn't wanted, but I'm wondering about the broader issue of adding new records to a database table. I have done some more thinking on this one, and experimenting with various other DB applications to see how the New Record functions work. It appears that the behaviour is not always consistent - for example, if you are inputing a new row in a table grid, the data appears to get saved automatically when you do a row change. However, if you simply exit the table without changing rows, the data in the input row does not get saved, and the newly inputted record will be lost. I know this inconsistency caused me some trouble until I figured out what you had to do to save an input record.

In my case, I want a form where the user can input info for a new record, and then be in control of when that info gets added (ie. I would like the record added only when the user presses a button), rather than having the database updated automatically if the user switches tabs. So, I'm wondering what you think of the following idea:
- create a Dummy Table with a duplicate structure to the one that I want to input to, and create a single record in that table.
- bind my input form to the DummyTable, allowing modifications, but no additions or deletions
- when the user presses "Save", append the DummyTable record to the real table.
That way, the user can switch tabs at will, and the input record will stay intact, but not get added to the database until the user presses Save.
I think this implementation would work, but is it a good idea from a design perspective?
Anne
 
Posts: 25
Joined: Fri Feb 01, 2008 2:22 am

Re: Simulating tabs in a form.

Postby QuazzieEvil » Tue Jul 08, 2008 3:23 am

You can do that, but make sure that it is really what you want/need. Sometimes there are needs that require you to go against the design. But often that is not a good idea.

The nature of a form is to update a record when you either explicitely save it (push the save button) or move to another row. If you do not save prior to moving to another row, then you loose the update/insert buffer. When you refresh/reload a form, one of the actions that takes place is that the row pointer ters reset, and thus moved out of the current row which causes the record to be saved.

Another possible solution is to update the primary key programatically (such as when you move out of tab 1). You can get the last/MAX value for the primary key (if it is an int auto value), and add 1. Something like this:

Code: Select all   Expand viewCollapse view
REM yo can bind this code to the record change event (check to make sure that the
REM IsNew properyt of the form is true (new record/insert row)
rs=createUnoService("com.sun.star.sdb.RowSet")
With rs
  .ActiveConnection=Form.ActiveConnection REM Form is the current form
  .CommandType=2 REM
  .Command="SELECT MAX(PKNAME)+1 AS NEWPK FROM YOURTABLENAME"
.execute()
.first()
End With
REM NOW UPDATE THE CONTROL BOUND TO THE PRIMARY KEY COLUMN--ASSUME HERE ITS COLUMN INDEX 1
Form.getByName("PKCONTROL").BoundField.updateInt(rs.getInt(1) )
QuazzieEvil
Volunteer
 
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: Simulating tabs in a form.

Postby Anne » Tue Jul 08, 2008 7:19 pm

Quazzie Evil:
Thank you for all your help on this! I was able to get things working, thanks to your useful ideas. Most appreciated :D
Anne
 
Posts: 25
Joined: Fri Feb 01, 2008 2:22 am

Re: Simulating tabs in a form.

Postby Anne » Thu Jul 10, 2008 2:52 am

With rs
.ActiveConnection=Form.ActiveConnection REM Form is the current form
.CommandType=2 REM
.Command="SELECT MAX(PKNAME)+1 AS NEWPK FROM YOURTABLENAME"
.execute()
.first()


It appears that the command SELECT MAX(PKNAME)+1 AS NEWPK FROM YOURTABLE NAME will generate the next available auto index value UNLESS the most recent record from YOURTABLENAME has already been deleted. So, for example, if the last 2 Auto ID's generated were 255 and 256, and then you delete the record with ID 256, the command SELECT MAX(PKNAME)+1 will produce the result 256 (since the MAX(PKNAME) that is still in the table is 255). However, the next auto-generated ID will be 257, since 256 has already been used.

Is there a way of querying the system to find out what the next auto-increment value will be? (or, even to find out what the last auto-increment value used was?)
Anne
 
Posts: 25
Joined: Fri Feb 01, 2008 2:22 am

Re: Simulating tabs in a form.

Postby mmiissp » Sat Mar 28, 2009 6:09 am

Hi all

I have followed this thread with a lot of interest and have put together a tab-like form. But, some of the components are behaving strangely when (their sections are) made visible/hidden - very similar to the AUTO-ID box popping up in a different form. I am using 3.1 alpha which may be a factor but played briefly with 3.0 and had similar result.

The problem is mostly label controls disappearing (even while their section/form is showing) and table controls popping out of position when visible is toggled. The problem seems to be related to the end of the page. That is, with 1 or 2 sections and 1 or 2 forms, no problem. But with more (specifically at the position down the page - web view since it is a form - at around 186mm), anything overlapping that point seems to behave strangely.

I do not understand web view (view->web view) so well. The page settings (eg paper size) don't seem to effect it, BUT oddly enough when editing the sections/forms in this view a gap between the first and second pages (like when editing a regular text document in normal view mode) appears - SOMETIMES. It is this gap that seems to be the source of the problem.

This gap doesn't appear when using the form (read-only mode) but as mentioned the controls don't work properly. I have had some success using line breaks to shift sections further down the page to avoid this gap but it is clumsy and not highly effective.

I am trying to include ALL FORMS (10 or so in total) into one database 'form' writer document, since hiding/showing sections is a powerful way to make a really interactive interface.

Does anyone know if there is a way to set the page for no gap, or if this may be a bug, or has anyone had any similar issues with using sections to build interactive GUIs in database forms? Any suggestions/tips very welcome!

Thanks
Michael
OOo 3.0.X on Ms Windows XP
mmiissp
 
Posts: 3
Joined: Sat Mar 28, 2009 5:25 am

Re: Simulating tabs in a form.

Postby mmiissp » Sat Mar 28, 2009 6:15 am

Here is the Base file I am using. It uses the internal HSQL database. There is no data at the moment - the form to use is EMPLOYEES. Also, I found showing all sections first and then hiding them (in the init sub on startup) seemed to reduce the problems - but only so far.

To reproduce some problems,
1) open a form then close (the "HOME" text should not disappear when all forms are closed);
2) open Courses, open a course, open the schedule sub window (click on the title bar) - this is OK BUT, close the course detail, then open another course (go back to the course detail windows) and the title bar text is missing (because course detail 'basic' and 'schedules' are open at the same time, they cross that gap between pages??).

You can find more sections/forms if you edit, but they aren't used at the moment.

Again Using 3.1 alpha - this may be an issue.

There is macro code, pretty basic to show/hide sections when on button clicks. So far, very little work with data - just the GUI.
funnysections.odb
(46.89 KiB) Downloaded 398 times



Thanks!
OOo 3.0.X on Ms Windows XP
mmiissp
 
Posts: 3
Joined: Sat Mar 28, 2009 5:25 am

Postby Robby » Sat Mar 28, 2009 9:04 am

xxx
Last edited by Robby on Sun Dec 11, 2011 9:53 am, edited 1 time in total.
Robby
 

Re: Simulating tabs in a form.

Postby Villeroy » Sat Mar 28, 2009 11:28 am

Robby wrote:The Form part of Base is completely unstable. Controls are spontaneously vanishing all the time, resulting in severe data loss. There seem to be no programmers working on Base so there is no progress as far as I can tell. It made me stop using it. May be in a few years...

Welcome to the club. Seemingly the project is driven by no more than 5 professional developers while a few more Basic-coders try their very best to inhale some breath into the body.
I can offer a sloppy form design utilizing the page view, page headers and footers with hyperlinks to bookmarks. You can also use the bookmark section in Writer's navigator.
Navigation through bookmarks is a little bit diffuse, but it works. The different sections are not hidden, just separated by page breaks, but why bother? No Basic, no cry.
shopping.odb
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 27895
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Simulating tabs in a form.

Postby mmiissp » Mon Mar 30, 2009 3:12 pm

Hi all

An interesting update for anyone working on using Text Sections to make database forms:

* Setting the background color for label controls stops them from disappearing suddenly

The strange behaviour that occurs when the background is set to (or left on) 'Default' is seemingly eliminated. Also, and similar to earlier posts in this thread:

* Setting Enabled=false for controls on forms to be hidden (by hiding Text Sections) seemingly eliminates the phantom text boxes appearing on top of other active forms.

This makes sense I guess in that if not enabled they cant get the focus, unintentionally or otherwise.

I am still interested to hear from anyone having similar issues...

Michael
OOo 3.0.X on Ms Windows XP
mmiissp
 
Posts: 3
Joined: Sat Mar 28, 2009 5:25 am

Re: Simulating tabs in a form.

Postby anonym » Mon Sep 28, 2009 2:43 pm

Hello,

when i was looking for tabs in OOo and couldn't find any,
i searched for an alternative and found this posting.

I "adopted" this solution in my frontend and basically it
works as expected, except for one thing:

One TextArea needs to be refreshed after it was hidden
and is being showed again, because all controls and
drawings arent shown.

A general refresh with
Code: Select all   Expand viewCollapse view
StarDesktop.getCurrentComponent().refresh()

didn't work.

Can someone help me with that problem?

Thanks in advance.
OpenOffice 3.1 on Windows XP and Debian 5
anonym
 
Posts: 4
Joined: Mon Sep 28, 2009 12:17 pm

Re: Simulating tabs in a form.

Postby RPG » Mon Sep 28, 2009 3:20 pm

Hello

I think you mean refresh a form.

reload all your main forms: mainform.reload.
For each mainform.

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2189
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Simulating tabs in a form.

Postby anonym » Mon Sep 28, 2009 4:00 pm

This didn't work either, although the idea seems to be the solution.

I made an event on of of the controls, so i can see if it is only not
being showed or if it is "disappeared".

Before the textsection is hidden, the event occurs (a msgbox), but
after being hidden and being set to visible again, no msgbox comes
up, if i go to the position where the control with this event should be.

Any ideas what the problem is?
Finding solutions withoug even knowing what the problem is, is damned.
OpenOffice 3.1 on Windows XP and Debian 5
anonym
 
Posts: 4
Joined: Mon Sep 28, 2009 12:17 pm

Re: Simulating tabs in a form.

Postby RPG » Mon Sep 28, 2009 5:33 pm

Hello

You badly explain what is your problem. You makes no difference between problems with the text part or with the table /form parts.

This mean that you have no clear point where you can search. For some people who are just started with porgramming and started with programming in OOo it is to difficult.
The form are part of the writer document and display the tables. This means when you have a problem it is real important to understand wich part gives the problem. I give an answer for the form part what is connect with the tables. But in the last post it seemes you have a problem with the writer part of your document.

So make clear, first to your self, what is the problem?

Before you start with this kind of programming it can be more easy to use the possibillities of the forms. I do have the idea that the form are tabspages for there own. I do use a kind of tabpages but that are frames for easy things. For the more complex forms with tabpage I think use also more forms as writer documents.

Maybe this link give you some information about section
http://www.oooforum.org/forum/viewtopic ... multi+form

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2189
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Simulating tabs in a form.

Postby anonym » Sun Oct 11, 2009 2:12 pm

Heres a short summary of what i did:
    Created the textsections. (left it with one blank line)
    Inserted a dimensioned frame into each section, which is anchored "as character".
    Put the forms into the frame, anchored to the frame.

This is basically fine without one restriction with anchoring:
"To Site" - Always visible on the same position (not to exert for tabs but logical)
"As Character" - Always on top-left corner of the frame/section and shifting. (best for frames)
"To Character" - Always on the same position within the frame which is shifting.
"To Paragraph" - Same as Character.
"To Frame" - Gets lost after Hiding.

And this is my problem. I need to leave the controls anchored to the frame
for the ease of layouting. Has anybody any idea how to solve this.

pitonyak wrote:Is there a good way to simulate "tabs" in a form?

DrewJensen wrote:Forms are ODF text files, yes?
ODF text files can have sections, yes?
Sections can contain frames, Yes?
Controls can be anchored to frames...yes?
Sections can be hidden - and - unhidden...???

Robby wrote:The method...is a bit nasty...they would shift...But the hidden subForms seem to occupy there one space anyhow.

QuazzieEvil wrote:Sections are a way to divide a text document...you can access them from the TextSections property of the form document model...If you bind this sub to all the tab buttons, it will show/hide the respective section.

Robby wrote:How do I get the Form objects into the sections?

DrewJensen wrote:Try putting a frame into the section and dropping onto the frame.

Robby wrote:It's working very very well and very very fast.

Robby wrote:It is extremely frustrating to try to get 4 boxes (with the controls positioned in it) rightly anchored/positioned to the section. I'm trying all sorts of settings but I'm not really successful. And the Boxes seem to slow down the tabs....

DrewJensen wrote:bad ideas it seems, that doesn't work at all. Anchoring 'To Character' seems to work the best, for me anyway.

Robby wrote:When the form is opened again these controls can be on the strangest places on the form. Looking as if the Database file is corrupt. When I group the buttons they seem to keep each other in place.

mmiissp wrote:...The problem is mostly label controls disappearing (even while their section/form is showing) and table controls popping out of position when visible is toggled...


--
PS:
Yes, my english got worse. It will get better ;)
OpenOffice 3.1 on Windows XP and Debian 5
anonym
 
Posts: 4
Joined: Mon Sep 28, 2009 12:17 pm

Re: Simulating tabs in a form.

Postby RPG » Sun Oct 11, 2009 10:18 pm

Hello

anonym wrote:And this is my problem. I need to leave the controls anchored to the frame
for the ease of layouting. Has anybody any idea how to solve this.

I donot understand what this means. My English is also poor.
Does it means that you do not want to anchor the controls to a frame?
If this is true then I think you have done something wrong!

What reason do you have to anchor the controls in an other way?

The section on a screen is greater or have the same size as the frame.
The frame is complete inside the section.

Romke
Attachments
sample_section_frame.odt
Sample for a frame inside a section
(8.2 KiB) Downloaded 323 times
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2189
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Simulating tabs in a form.

Postby anonym » Sun Oct 11, 2009 10:34 pm

Nono, i meant that the controls must be anchored to the frame
and they are anchored to the frame, but after the frame was
hidden once and is being set to visible again, all controls which
are anchored to the frame are vanished while those anchored
to the paragraph reappear.

But only if i anchore them to the frame, they will always be
positioned at the right place, so you might see what my
problem is.
OpenOffice 3.1 on Windows XP and Debian 5
anonym
 
Posts: 4
Joined: Mon Sep 28, 2009 12:17 pm

Re: Simulating tabs in a form.

Postby RPG » Sun Oct 11, 2009 11:43 pm

Hello

It take some time before I understand your problem.
I think there is not a solution for this. I did test it also with OOo 2.4.2 with Windows XP and I have there the same error as you describe. I have also this error with Linux OOo3.1.1.

Why do I think there is no solution. In the new version of OOo 3.2 they make possible to change the visibility of a control and maybe there is already something changed in the code.

I have some files from Robby. That are complex files and made in an early version. On this moment the old files are working good. A new file is working bad.

I think the only solution is waiting on the new version of OOo 3.2 or go back to an old version but I think this give also problems see my test.

What you describe was not in earlier version. I do not know which version start with this problem.

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2189
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Simulating tabs in a form.

Postby RPG » Mon Oct 12, 2009 11:09 am

Hello

I have test a little more. But first I do not use section in forms only frames.
Maybe you must change your mind and remove the frames from your forms and anchor all the controls to a section or paragraph.
I did only test only with one section and one control

I do remember me that the frames are used for an other problem and maybe the solution is now do not use frames more.

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2189
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Simulating tabs in a form.

Postby atandb » Sun Dec 12, 2010 8:31 pm

Very nice discussion. I changed a few things so that one did not have to know the names of all the sections to make them invisible, and I assume that I am always going to name the sections as the button's label plus "Section". Alternately I could have taken the name rather than the label, choped off the "Tab" at the end and concated "Section". If you are consistent in your naming convention this should work. The problem would be if you wanted a space in the label of course. I hate the way capital "I" shows up in this forum, so I am switching the case for this comment.

Sub TabControlButtons_OnClick(Event As Object)
Dim Button As String
Dim FormDoc As object
Dim SectionName As String
Dim CurrState As Boolean
Button=Event.Source.Model.Label
FormDoc=Event.Source.Model.Parent.Parent.Parent
SectionName = Button & "Section"
' FormDoc.TextSections(0).IsVisible=True 'Don't turn this one off or no more buttons!!!
for i = 1 to FormDoc.TextSections.Count-1 'Turn them all off, including the one we want up.
FormDoc.TextSections(i).IsVisible=False
next i
FormDoc.TextSections.getByName(SectionName).IsVisible=True
End Sub
OpenOffice vs 3.2.1
Windows 7
atandb
 
Posts: 1
Joined: Sun Dec 12, 2010 8:21 pm

Re: Simulating tabs in a form.

Postby RPG » Sun Dec 12, 2010 8:54 pm

Hello

It seems you understand macros, then maybe this can be good for you.

I have the idea you can better use frames then section for your tabs

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2189
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Previous

Return to Forms

Who is online

Users browsing this forum: No registered users and 4 guests