Equivalent to MS Access Me.dirty function

Getting your data onto paper - or the web - Discussing the reports features of Base

Equivalent to MS Access Me.dirty function

Postby andyonio » Tue Jun 16, 2015 1:55 pm

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
andyonio
 
Posts: 7
Joined: Tue Jun 16, 2015 1:41 pm

Re: Equivalent to MS Access Me.dirty function

Postby Villeroy » Wed Jun 17, 2015 8:53 am

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   Expand viewCollapse view
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, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26379
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Equivalent to MS Access Me.dirty function

Postby andyonio » Thu Jun 18, 2015 6:39 pm

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
andyonio
 
Posts: 7
Joined: Tue Jun 16, 2015 1:41 pm

Re: Equivalent to MS Access Me.dirty function

Postby Villeroy » Thu Jun 18, 2015 9:17 pm

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, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26379
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Equivalent to MS Access Me.dirty function

Postby andyonio » Thu Jun 18, 2015 11:49 pm

The extension manager gives me the following error message
Connector : couldn't connect to pipe 1fa954d3caea0142e48b388dd7fbf9453c9f9480d8a3f4ca5cb7618b36350(1)
LibreOffice 4.1 on Windows XP
andyonio
 
Posts: 7
Joined: Tue Jun 16, 2015 1:41 pm

Re: Equivalent to MS Access Me.dirty function

Postby Villeroy » Fri Jun 19, 2015 12:02 am

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, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26379
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Equivalent to MS Access Me.dirty function

Postby andyonio » Fri Jun 19, 2015 9:10 am

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
andyonio
 
Posts: 7
Joined: Tue Jun 16, 2015 1:41 pm

Re: Equivalent to MS Access Me.dirty function

Postby Villeroy » Fri Jun 19, 2015 6:21 pm

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, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26379
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Equivalent to MS Access Me.dirty function

Postby Nocton » Sun Jul 05, 2015 2:56 pm

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   Expand viewCollapse view
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.2.0 on Windows 10
Nocton
Volunteer
 
Posts: 494
Joined: Fri Nov 05, 2010 10:27 am
Location: UK

Re: Equivalent to MS Access Me.dirty function

Postby andyonio » Sun Jul 05, 2015 7:37 pm

Thanks, I' ll try as soon as possible.
LibreOffice 4.1 on Windows XP
andyonio
 
Posts: 7
Joined: Tue Jun 16, 2015 1:41 pm


Return to Reporting

Who is online

Users browsing this forum: No registered users and 1 guest