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

BASE: Creating Basic Navigation

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Koronis
Newbie
Newbie


Joined: 10 Mar 2012
Posts: 2

PostPosted: Sat Mar 10, 2012 12:45 pm    Post subject: BASE: Creating Basic Navigation Reply with quote

Im a marketing guy who has played extensively with Access, but i'm not a coder. im an expert at creating affiliates and relationships but I usually have a team to clean up the mess.

I want to create my own buttons to navigate between forms I create;
- tried to record macro go this when linked to button;
I got an errer that says" basic syntax error parenthesis don't match"

this is the macro;

Code:
Sub Client Main_AfterRecordChange(Event As Object)
   Dim Form As Object
   Dim bModel As Object
   Dim bControl As Object
   Dim Disable As Boolean
   
   Form=Event.Source
   bModel=Form.getByName("pbNext")
   bControl=Form.Parent.Parent.CurrentController.getControl(bModel)
   Disable=Form.isLast() or Form.isAfterLast()
   bControl.Enable=Not(Disable)
End Sub


I also looked around in the menus but found no easy way... is there one? I would also like to open and close forms! im keeping it simple for my audience

Please help

Tagged code - floris v, moderator

Moderation probe1: moved to MACROS AND API section, where all macro related questions belong to; edited subject
_________________
Donald Baylis
647-924-8544
Back to top
View user's profile Send private message
brian4m
OOo Enthusiast
OOo Enthusiast


Joined: 13 Feb 2006
Posts: 162
Location: Bath, England

PostPosted: Sun Mar 11, 2012 3:38 am    Post subject: Reply with quote

This works for me.

To open a form, called LIST_OF_SURNAMES, from Form1. Insert a button in Form1 and link it to the following macro

Code:
sub Open_LIST_OF_SURNAMES
dim oCurrentController
'Variables for document what will be opened
dim sNewfileFormName ' This is the name how it is in the database
dim oNewformtoSee ' Object for the new form what will beopend
sNewfileFormName="LIST_OF_SURNAMES" 'is a writer form it must be in this database
oCurrentController=ThisDatabaseDocument.CurrentController
if  ThisDatabaseDocument.FormDocuments.hasbyname(sNewfileFormName) then
   ' the form exist and can maybe opend
   oNewformtoSee=oCurrentController.loadComponent(com.sun.star.sdb.application.DatabaseObject.FORM,sNewfileFormName,FALSE) ' or TRUE for editing the documentwait 10
else
      msgbox "The does not exist and cannot be opend"
      end
end if
end sub


To close that LIST_OF_SURNAMES form insert a button and link it to this macro.
sub CloseThisform
sFormName = "LIST_OF_SURNAMES"
ThisDatabaseDocument.FormDocuments.getbyname(sFormName).close
end sub

Brian

Tagged code - floris v, moderator
Back to top
View user's profile Send private message
Koronis
Newbie
Newbie


Joined: 10 Mar 2012
Posts: 2

PostPosted: Tue Mar 13, 2012 3:35 pm    Post subject: Reply with quote

Thank you so much for your help, I created the macro;

Code:
sub Open_Main_Contact
dim oCurrentController
'Variables for document what will be opened
dim sNewfileFormName ' This is the name how it is in the database
dim oNewformtoSee ' Object for the new form what will beopend
sNewfileFormName="Main_Contact" 'is a writer form it must be in this database
oCurrentController=ThisDatabaseDocument.CurrentController
if ThisDatabaseDocument.FormDocuments.hasbyname(sNewfileFormName) then
' the form exist and can maybe opend
oNewformtoSee=oCurrentController.loadComponent(com.sun.star.sdb.application.DatabaseObject.FORM,sNewfileFormName,FALSE) ' or TRUE for editing the documentwait 10
else
msgbox "The does not exist and cannot be opend"
end
end if
end sub


But i'm geting error : "BASIC runtime error object variable not set"

Tagged code - floris v, moderator
_________________
Donald Baylis
647-924-8544
Back to top
View user's profile Send private message
brian4m
OOo Enthusiast
OOo Enthusiast


Joined: 13 Feb 2006
Posts: 162
Location: Bath, England

PostPosted: Wed Mar 21, 2012 11:50 am    Post subject: Reply with quote

Donald

You have not stated the error but have given no reference to the line that has the problem.

As far as I can see the sixth line is the difference. That suggests that the form, "Main_Contact", is either missing or, more likely, mis-spelled.

Brian
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