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

[Solved] Report from one record in a form

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
Zeke99
Newbie
Newbie


Joined: 30 May 2011
Posts: 4

PostPosted: Mon May 30, 2011 10:57 am    Post subject: [Solved] Report from one record in a form Reply with quote

Hi

I have a table named customertable with three textfields, Name, Adress, POadress and a keyfield (integer) named ID.
I have a form ,customerform, were I can view one record a time, txtName, txtAdress, txtPOadress and ID.
I have a report, customerreport.odt (made by Oracle report builder) with three fields, Name, Adress and POadress.

Now I want a button in my form to push when I want to print an adresslabel.
Any idea what to put between

sub printadresslabel

...

end sub

in order to print only the fields for the active record just showing in the form.


Last edited by Zeke99 on Wed Jun 01, 2011 11:32 pm; edited 1 time in total
Back to top
View user's profile Send private message
dniezby
OOo Enthusiast
OOo Enthusiast


Joined: 01 May 2004
Posts: 102

PostPosted: Tue May 31, 2011 6:32 am    Post subject: Reply with quote

I'm still learning a lot right now but I would say create a mailmerge document and select the database you've created as it's source. Then you can create all the labels you want even print specific ones.
Back to top
View user's profile Send private message
Zeke99
Newbie
Newbie


Joined: 30 May 2011
Posts: 4

PostPosted: Tue May 31, 2011 8:18 am    Post subject: Reply with quote

I have never used a mailmerge document so I'm unfamiliar with that. Can you activate it from a pushbutton inside a form? How do you write the macro for that?

If I use the macro below I print a copy of the current form.

sub printest

Dim aPrintOps(0) As New com.sun.star.beans.PropertyValue
oDoc = ThisComponent
oVCurs = oDoc.CurrentController.getViewCursor()
aPrintOps(0).Name = "Pages"
aPrintOps(0).Value = trim(str(oVCurs.getPage()))
oDoc.print(aPrintOps())

end sub

But I want to be able to use a report from Oracle report builder. Any suggestions?
Back to top
View user's profile Send private message
dniezby
OOo Enthusiast
OOo Enthusiast


Joined: 01 May 2004
Posts: 102

PostPosted: Tue May 31, 2011 8:55 am    Post subject: Reply with quote

From what I know, you'd create the document separately.

You could just use the mail merge wizard to create a sample document to practice with.

Then in the form within your database, you'd simply create a push button on your form.

To open the mail merge document, edit the push button control to

Action: Open form/url

Then you will be prompted to select the file you want to open. Select that merged document.

At least that's the way I'd try to go.

No macro writing needed.

You seem excited to jump right into writing macros? Try starting with simple methods first. There usually is a simple method for everything and more efficient.
Back to top
View user's profile Send private message
Zeke99
Newbie
Newbie


Joined: 30 May 2011
Posts: 4

PostPosted: Tue May 31, 2011 12:51 pm    Post subject: Reply with quote

I'm replacing a company business system. The company is migrating from Windows to Linux. There are many users, some computer wizards and some on neanderthal level. It's atmost important that everything is selfexplaning, easy to use and foolproof. When you push that button in the form there must be no extra forms or dialog popping up, just the document coming out from the printer.

Getting the keyfield from the form is working

sub getfromtextbox (Event As Object)
Dim Form As Object
Dim KeyTxt As Object

Form=Event.Source.Model.Parent
KeyTxt=Form.GetByName("txtkeyfield")
....
....
End Sub

Opening and printing the report is working.

Sub OpenAdressReport(oEvent As Object)
Dim RptName as string
RptName = "AdressLabel"
ThisDatabaseDocument.ReportDocuments.getByName(RptName).open
End Sub

It's just the method or syntax to get the keyfield filtering the report that missing.

In Access there was an OpenReport-macro where you could put a SQL-expression like [DELKEY]=[Form]![Formname]![DELKEY].

I suppose I could base the report on a Query but I still need to put the KeyField into that SQL-expression without the user doing anything except pushing that button in the form.
Back to top
View user's profile Send private message
Zeke99
Newbie
Newbie


Joined: 30 May 2011
Posts: 4

PostPosted: Wed Jun 01, 2011 11:29 pm    Post subject: Reply with quote

Amazing what a good nights sleep can do.
It's not ideal but this solution works for now. The cost is an extra character to every record.

I attach an extra field, FilterPrint, to the table Customertable.
In Oracle Report Builder I set a Filter condition FilterPrint='P'
To the pushbutton in my form I connect the macro below:

REM ***********************************
REM
REM Open a report from a push on
REM a pushbutton in a form
REM
REM The table needs an extra field
REM (FilterPrint) that can be
REM filtered by the report
REM
REM ***********************************

Sub OpenMyReport(Event As Object)

Dim RptName as string

Dim Form As Object
Dim Txt As Object
Dim Column as object

Form=Event.Source.Model.Parent
REM Make the connection to the form

Column=Form.Columns.GetByName("FilterPrint")
Column.updateString("P")
REM Put a P in the FilterPrint textbox

Form.updateRow()
REM Update the table

RptName = "Kundrapport"
REM the name of the report I want to open

ThisDatabaseDocument.ReportDocuments.getByName(RptName).open
REM Open the report

Column=Form.Columns.GetByName("FilterPrint")
Column.updateString("N")
REM Put an N in the FilterPrint textbox

Form.updateRow()
REM Update the table

End Sub
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 Base 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