FlowFact - Entwicklungstools v19.881 FLOWFACT 2017 R2 - Function - Det_SetValue

Detailwert setzen

Function Det_SetValue(ByVal strTable As String, ByVal strTableDsn As String, ByVal strFldArtDsn As String, strValue As String, Optional ByVal strAcl As String = STRNOTHING, Optional ByVal strLinkDsn As String = STRNOTHING) As Boolean


strTable: Tabellenname der Haupttabelle
strTableDsn: Datensatznummer der Haupttabelle z.B. AD, Obj ...
strFldArtDsn: Die Datensatznummer (DSN) der FeldArt
strValue: Der Detailwert
OPTIONAL strACL: Berechtigung (siehe EMSK_GetDefaultACL)
OPTIONAL strLinkDsn: Datensatznummer (DSN) z.B. einer verküpften Adresse (nur zulässig, wenn Feldart vom Typ Adresse od. Projekt)
Rückgabewert: = True, wenn der Detailwert gesetzt werden konnte; sonst = False


Public Function Det_SetValue(ByVal strTable As String, ByVal strTableDsn As String, ByVal strFldArtDsn As String, strValue As String, Optional ByVal strAcl As String = STRNOTHING, Optional ByVal strLinkDsn As String = STRNOTHING) As Boolean
    Dim bResult As Boolean
    Dim rs As ADODB.Recordset
    Dim strSQL As String
    Dim strTblDet As String

    bResult = False

    strTblDet = UCase(strTable) & "DET"
    If strFldArtDsn <> "" And strTable <> "" And strTableDsn <> "" Then
        'Immer über Haupttabelle auf Det-Tabelle zugreifen, wg. Berechtigung
        'Bei mehrfachen Detail-Felder wird das erste in der Tabelle genommen (Sortierung nach DSN)
        strSQL = "SELECT " & strTblDet & ".* " & _
                  "FROM " & strTable & " INNER JOIN " & strTblDet & " ON " & strTable & ".dsn = " & strTblDet & "." & strTable & "_dsn " & _
                  "WHERE (" & strTable & ".DSN=" & m_oUtil.SqlUid(strTableDsn) & ") AND (" & strTblDet & ".FLDART_DSN=" & m_oUtil.SqlUid(strFldArtDsn) & ") " & _
                  "ORDER BY " & strTblDet & ".DSN"
        Set rs = FF_GetRecordset(strSQL)
        If rs.EOF = True Then
            rs.AddNew
            rs("DSN").value = m_oUtil.NewGUID()
            rs(strTable & "_DSN").value = m_oUtil.SqlStrNull(strTableDsn)
            rs("FldArt_DSN").value = m_oUtil.SqlStrNull(strFldArtDsn)
        End If
        rs("Eingabe").value = Mid(strValue, 1, 100)

        If strAcl <> STRNOTHING Then
            rs("ACL").value = strAcl
        End If

        If strLinkDsn <> STRNOTHING Then
            rs("Link_DSN").value = m_oUtil.SqlStrNull(strLinkDsn)
        End If

        FF_UpdateRecordset rs
        bResult = True
        Set rs = Nothing
    End If
    Det_SetValue = bResult
End Function