Equivalent to MS Access Me.dirty function

Getting your data onto paper - or the web - Discussing the reports features of Base
Post Reply
andyonio
Posts: 7
Joined: Tue Jun 16, 2015 1:41 pm

Equivalent to MS Access Me.dirty function

Post by andyonio »

How do you print just the one record you are viewing in the form?
Create a report, to get the layout right for printing. Use the primary key value that uniquely identifies the record in the form, and open the report with just that one record.

This code works in MS Access
http://allenbrowne.com/casu-15.html


Private Sub cmdPrint_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub



Can anyone translate this macro into LibreOffice Basic for me?

Thanks
LibreOffice 4.1 on Windows XP
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Equivalent to MS Access Me.dirty function

Post by Villeroy »

The following snippet has been generated by the MRI tool while browsing the calling event struct.
[Tutorial] Introduction into object inspection with MRI
Object oInitialTarget is the event struct http://www.openoffice.org/api/docs/comm ... Event.html passed by the button.
The source of the struct is the visible representation of the button object which has a model (blue print).
The parent of the model is the form where the button model belongs to and that one as a property isModified [boolean].

Code: Select all

Sub Snippet(Optional oInitialTarget As Object)
  Dim oSource As Variant
  Dim oModel As Variant
  Dim oParent As Variant
  Dim bIsModified As Boolean

  oSource = oInitialTarget.Source
  oModel = oSource.getModel()
  oParent = oModel.getParent()
  
  bIsModified = oParent.IsModified
End Sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
andyonio
Posts: 7
Joined: Tue Jun 16, 2015 1:41 pm

Re: Equivalent to MS Access Me.dirty function

Post by andyonio »

Unfortunately I am not able to to run MRI. I have Libreoffice 4.4 on XP.
Would any other OpenOffice release work?

Thanks
LibreOffice 4.1 on Windows XP
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Equivalent to MS Access Me.dirty function

Post by Villeroy »

I did it with LO4 and MRI. Install the OpenOffice version. It works fine with LO4. http://extensions.openoffice.org/en/pro ... ction-tool

P.S. Being a database developer, you should be able to give a clear problem description.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
andyonio
Posts: 7
Joined: Tue Jun 16, 2015 1:41 pm

Re: Equivalent to MS Access Me.dirty function

Post by andyonio »

The extension manager gives me the following error message
Connector : couldn't connect to pipe 1fa954d3caea0142e48b388dd7fbf9453c9f9480d8a3f4ca5cb7618b36350(1)
LibreOffice 4.1 on Windows XP
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Equivalent to MS Access Me.dirty function

Post by Villeroy »

did you install LibreOffice without Python support?
Open a new Writer doc.
Call Tools>Macros>Organize>Python...
Call LibreOffice Macros>HelloWorld>HelloWorldMacro
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
andyonio
Posts: 7
Joined: Tue Jun 16, 2015 1:41 pm

Re: Equivalent to MS Access Me.dirty function

Post by andyonio »

I did what you said.

Hello World (in Python) is written in the blank page.

Could it be a Java problem?

Anyway MRI UNO inspection tool appears in the list if extensions. When I press enable, the error message appears. :?:

I plan to install windows 7, reinstall Java.

Thanks, I will let you know.

It would be wonderful if you wrote the complete translation of the MS Access subroutine so that I could attach it to a pushbutton. The MS Access subroutine enables me to print the present record in a queary without problems. I want to move to Openoffice, but I have limited knowledge of object oriented programming. If the record could be printed as text to the clipboard, I would have solved my problem.
LibreOffice 4.1 on Windows XP
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Equivalent to MS Access Me.dirty function

Post by Villeroy »

No, it is not a Java problem. I can run MRI with Java disabled or with no byte of Java on the entire system. I don't know what the problem is. I do not develop anything on Windows.

Do you know the Access2Base extension?
http://extensions.libreoffice.org/exten ... ccess2base
http://www.access2base.com/access2base.html
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Nocton
Volunteer
Posts: 533
Joined: Fri Nov 05, 2010 10:27 am
Location: UK

Re: Equivalent to MS Access Me.dirty function

Post by Nocton »

How do you print just the one record you are viewing in the form?
This is how I do it:
1. Create table (FilterID) with one record to hold the ID of the record you wish to print.
2. Create Query using FilterID to set relationship to the record required and use this data source for your report.
3. On main form (MainForm) add text box (fldGroupID) with data field set to required ID.
4. On main form set up 'FilterForm' subform with data source FilterID table and with text box 'fldGroupID' with data field set to selected/filter ID.
5. Call following code from 'Before record action' event of main form:

Code: Select all

Sub FilterID_update 
dim oForm1,oForm2 as object
dim sText1 as string 
oForm1=ThisComponent.Drawpage.Forms.getByName("MainForm") 
sText1 = oForm1.getByName("fldGroupID").currentvalue
oForm2=oForm1.getByName("FilterForm")
oStatement = oForm2.ActiveConnection.createStatement() 'Create an SQL statement object
sSQL = "UPDATE ""FilterReport"" " & " SET ""FilterID"" = " & sText1
oStatement.executeUpdate( sSQL ) 
End Sub 
This updates the FilterID table so that when you call your report only the selected record prints. When all works OK, just make the ID text boxes not visible.

Regards,
Nocton
OpenOffice 4.1.12 on Windows 10
andyonio
Posts: 7
Joined: Tue Jun 16, 2015 1:41 pm

Re: Equivalent to MS Access Me.dirty function

Post by andyonio »

Thanks, I' ll try as soon as possible.
LibreOffice 4.1 on Windows XP
Post Reply