Feld mit Bedingung

Antwort erstellen


BBCode ist eingeschaltet
[img] ist ausgeschaltet
[url] ist eingeschaltet
Smileys sind ausgeschaltet

Die letzten Beiträge des Themas
   

Ansicht erweitern Die letzten Beiträge des Themas: Feld mit Bedingung

Feld mit Bedingung

von moritz » Mo, 24.09.2007 20:19

Hallo, Ihr
bin schon wieder auf ein kleines Problem gestoßen.
Ich möchte einen Datensatz aus der Datenbankleisten automatisch in die Felder eines Serienbriefes eintragen. Grundsätzlich funktioniert das auch mit dem folgenden Code.
Es gibt aber auch bedingte Felder, die von Serienfeldern abhängig sind. Wenn also die Anrede "Herr" ist, muß das Feld nach z. Hdn. von Herr "n" anzeigen. Wie kann man mit Basic auf diese Felder zugreifen, daß sie das gewünschte Ergebnis zeigen?
Hier der Code
Sub DataToFields '(oDoc) 'Version 2, John C. Vigor, Jr. 2/25/07
'Credit to Bernard Marcelly, Marc Santhoff, Frank Schönheit, Paolo Mantovani
'and Fernand for the difficult portion of the code in the "RowSelectionInDataBrowser"
'function:
' http://codesnippets.services.openoffice ... ethod.snip
'This function has otherwise been butchered by me.
BasicLibraries.LoadLibrary("XrayTool")
Dim DBname,tableName,DBrow,oEnum,thisField
Dim TFM,fieldName,s$,a$,iAns,ExtraFN,ExtraDB
oDoc = ThisComponent
REM Get the database row 0, database name and table name.
DBrow = RowSelectionInDataBrowser(oDoc,DBname,tableName)
oEnum = oDoc.getTextFields.createEnumeration 'Enumerate text fields.
While oEnum.hasMoreElements
thisField = oEnum.nextElement

If thisField.SupportsService("com.sun.star.text.TextField.ConditionalText") then
if thisfield.Condition= "Title == ""Herr""" then
xray thisfield
[size=150]Das ist die Stelle, wo ich nicht mehr weiter weiß. Hat jemand eine Idee oder einen Lösungsansatz?[/size]
' thisfield.IsConditionTrue = true
end if
end if
If thisField.SupportsService("com.sun.star.text.TextField.Database") then 'Its a DB field.
TFM = thisField.getTextFieldMaster 'Get text field master.
If TFM.DataBaseName = DBname then 'The field is from the current database.
TFM.DataTableName = tableName 'Set text field master to selected table.
fieldName = TFM.DataColumnName 'Get the field name.
'msgbox fieldName
If DBrow.Columns.hasByName(fieldName) then 'Current DB row has this field name.
s$ = DBrow.Columns.getByName(fieldName).String 'Get desired presentation string.
thisField.CurrentPresentation = s$ 'Set the presentation.
Else ExtraFN = ExtraFN + 1 'Foreign field name count.
EndIf
Else ExtraDB = ExtraDB + 1 'Foreign database count.
Endif
EndIf
Wend
oDoc.Modified = true
End Sub

Function RowSelectionInDataBrowser(oDoc,DBname,tableName)
Dim frame1,frame2,oModel,oDataSourceBrowser
frame1 = oDoc.CurrentController.Frame
frame2 = frame1.findFrame("_beamer",4) ' get DataBrowser frame
oDataSourcebrowser = frame2.Controller
oModel = oDataSourcebrowser.com_sun_star_awt_XTabController_getModel
DBname = oModel.DataSourceName
tableName = oModel.Command
oModel.moveToBookmark(1)
RowSelectionInDataBrowser = oModel
End Function

Vielen Dank
Moritz

Nach oben