Page 1 of 1
Equivalent to MS Access Me.dirty function
Posted: Tue Jun 16, 2015 1:55 pm
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
Re: Equivalent to MS Access Me.dirty function
Posted: Wed Jun 17, 2015 8:53 am
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
Re: Equivalent to MS Access Me.dirty function
Posted: Thu Jun 18, 2015 6:39 pm
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
Re: Equivalent to MS Access Me.dirty function
Posted: Thu Jun 18, 2015 9:17 pm
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.
Re: Equivalent to MS Access Me.dirty function
Posted: Thu Jun 18, 2015 11:49 pm
by andyonio
The extension manager gives me the following error message
Connector : couldn't connect to pipe 1fa954d3caea0142e48b388dd7fbf9453c9f9480d8a3f4ca5cb7618b36350(1)
Re: Equivalent to MS Access Me.dirty function
Posted: Fri Jun 19, 2015 12:02 am
by Villeroy
did you install LibreOffice without Python support?
Open a new Writer doc.
Call Tools>Macros>Organize>Python...
Call LibreOffice Macros>HelloWorld>HelloWorldMacro
Re: Equivalent to MS Access Me.dirty function
Posted: Fri Jun 19, 2015 9:10 am
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.
Re: Equivalent to MS Access Me.dirty function
Posted: Fri Jun 19, 2015 6:21 pm
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
Re: Equivalent to MS Access Me.dirty function
Posted: Sun Jul 05, 2015 2:56 pm
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
Re: Equivalent to MS Access Me.dirty function
Posted: Sun Jul 05, 2015 7:37 pm
by andyonio
Thanks, I' ll try as soon as possible.