habe folgendes Makro erstellt:
Code: Alles auswählen
SUB AUTO_BEZAHLT
Dim sText As String, sSQL As String
Dim oStatement As Object, oReportDoc As Object, oVerbindung As Object
Dim Args(1) As New com.sun.star.beans.PropertyValue
Dim oDataBaseContext As Object, oDataSource As Object
oDataBaseContext = CreateUnoService ( "com.sun.star.sdb.DatabaseContext" )
oDataSource = oDataBaseContext.getByName( "DATENBANK" )
Dim oDoc as Object, oDrawpage as Object, oSubForm1 as Object, oDocCtl as Object, oDraw as Object, oSubForm as Object
Dim oFeld as Object
Dim la as String
oDoc = ThisComponent
oDrawpage = oDoc.drawpage
oForm = oDrawpage.forms.getByName ("KRG")
oSubForm = oForm.getByName("ZAHLART")
oSubForm1 = oForm.getByName("BEZAHLT_STEUERUNG")
oDocCtl = oDoc.getCurrentController()
oDraw = oDoc.drawpage
oForm = oDoc.drawpage.forms(0)
la = oForm.getByName("ZAHLART").text
IF la LIKE "B Barzahlung *" THEN
Dim a as string
a = Date()
oDoc = ThisComponent
oDocView = oDoc.getCurrentController()
oForm = oDoc.drawpage.forms(0)
oFeld = oForm.getByName("BEZAHLT")
oDocView.getControl(oFeld).setFocus()
oDocView.getControl(oFeld).text = cDate (a)
oDocView.getControl(oFeld).date = CDateToISO( Date )
ofeld.commit()
Code: Alles auswählen
ELSE
hier soll jetzt das Datumsfeld bei Nichterfüllung des Kriterioums leer bleiben (auch kein Problem ! )
ABER: Ist bereits ein Bezahlt-Datum abgespeichert, soll dieses bei Nichtzutreffen der Bedingung durch ein leeres Datumsfeld ersetzt werden.
Habe das auch schon mit einer Hilfstabelle ("BEZAHLT_STEUERUNG") mit ID und "leerem" Datum in einer SQL-Anweisung probiert:
Code: Alles auswählen
oDataBaseContext = CreateUnoService ( "com.sun.star.sdb.DatabaseContext" )
oDataSource = oDataBaseContext.getByName( "Datenbank" )
oVerbindung = oDataSource.getConnection( "" , "" )
oStatement = oVerbindung.createStatement
sSQL = "UPDATE ""Datenbank"" SET ""BEZAHLT"" = SELECT ""BEZAHLT"" FROM ""BEZAHLT_STEUERUNG"" WHERE ""Datenbank"".""ID""=
""BEZAHLT_STEUERUNG"".""ID"""
oStatement.executeUpdate( sSQL )
Bitte um Hilfe...Danke, Poller
Hoffe, ich habe mich verständlich ausgedrückt, arbeite mit OO4.1 u. Windows 10
Moderation,4: verschoben in BASIC-Unterbereich, wo alle Makro-Fragen hin gehören; Betreff angepasst; CODE tags gesetzt