dank eurer Hilfe ist es mir gelungen, meine Arbeit fast fertigzustellen-nochmals DANKE!.
Nur ein Problem bei der Datenpflege:
Bei der Eingabe soll das Textfeld in Großbuchstaben zum Suchen in Feld upper abgespeichert werden und bei der Datensatzart (mainparts) aus min und max der Mittelwert gebildet werden und in Feld ranking wegen Sortierung des Ergebnisses gespeichert werden.
Die berechnung etc. funktioniert-auch landen die Daten in der Datenbank.
Habe das Makro dem Ereignis "Vor Datensatzoperation" zugeordnet.
Beim Abspeichern bekomme ich bei Neueingabe eine Fehlermeldung, daß Update Row nur auf vorhandenen Datensätzen läuft.
Ändere ich einen vorhandenen Datensatz, so wird das Makro endlos aufgerufen.
Eigentlich suche ich nur eine Funktion, wie sie beim Einsatz von Triggern auf Datenbanke verwendet wird:
Insert or update.
Hier mein Code
Code: Alles auswählen
REM*** Berechnung des Mittelwertes aus Min und Max Feldern und Zuweisen an ranking Feld ***
REM*** Umwandlung des textfeldes in großbuchstaben und Zuweisen an upper Feld ***
dim Bas
dim oDocuments
dim Doc
dim oPage
dim oDrawPage
dim oElement
dim oElements
dim oSubForm
dim oColumns
dim oColumnMin
dim oColumnMax
dim oColumnAvg
dim oColumnItem
dim oColumnText
dim oColumnUpper
dim c as Double
dim d as Double
dim e as Double
dim a as Double
dim s as String
dim t as String
dim u as String
dim f as String
Sub avrg
msgbox("Start")
oBase = ThisDatabaseDocument
' xray oBase
oDocuments = oBase.getFormDocuments()
' xray oDocuments
oDoc = oDocuments.getByName("Datenpflege")
' xray oDoc
oPage = oDoc.getComponent()
' xray oPage
oDrawPage = oPage.DrawPage
' xray oDrawPage
oForms = oDrawPage.getForms()
' xray oForms
oElement = oForms.getByName("MainForm")
' xray oElement
oSubForm = oElement.getByName("Search")
' xray oSubForm
oColumns = oSubForm.getColumns()
' xray oColumns
oColumnMin = oColumns.getByName("min")
' xray oColumnMin
oColumnMax = oColumns.getByName("max")
' xray oColumnMax
oColumnAvg = oColumns.getByName("ranking")
' xray oColumnAvg
oColumnItem = oColumns.getByName("verknuepfung")
' xray oColumnItem
oColumnText = oColumns.getByName("text")
' xray oColumnItem
oColumnUpper = oColumns.getByName("upper")
' xray oColumnItem
t = oColumnText.string
f = oColumnUpper.string
'msgbox(t)
'msgbox(f)
t = Trim(t)
u = UCase(t)
'msgbox(u)
oColumns.getByName("upper").updateString(u)
s = oColumnItem.string
'msgbox(s)
if s = "mainparts" Then
a = oColumnAvg.Float
c = oColumnMin.Float
d = oColumnMax.Float
e = (c+d)/2
'msgbox(e)
oColumns.getByName("ranking").updateFloat(e)
c = 0
d = 0
e = 0
End If
If (u <> f) or (a <> e) Then
oSubForm.updateRow()
Exit Sub
End If
End Sub
Rudi