von Pixelletter » Di, 18.06.2013 13:32
das hilft. Ich hatte schon befürchtet, ich müsste alle Datensätze überarbeiten um nach ,ID, suchen zu können, aber das hier ist viel besser. Vielen Danke
Btw. Ich glaube, du hast vergessen, sID = SQL_Result.getstring (1) zu setzen, um den passenden Datensatz zu suchen.
Wen's interessiert: der fertige Code sieht jetzt so aus:
Code: Alles auswählen
Sub S_CheckID
oform = thiscomponent.drawpage.Forms.MainForm
oconnection = oform.activeconnection
SQL_Statement = oconnection.createstatement
sSQL = "SELECT ""ID"", ""weitere IDs"" FROM ""Bestand_Videos"""
SQL_Result = SQL_Statement.executequery(sSQL)
otxtID = oform.txtID
sID = otxtID.text
sIDSafe = sID
while SQL_Result.next
if SQL_Result.getstring(1) = sID then' or instr(SQL_Result.getstring(2),sID) > 0 then
sID = SQL_Result.getstring(1)
msgbox "ID schon vorhanden. OK zum suchen des Datensatzes"
DialogLibraries.LoadLibrary("Standard")
oDialog1 = CreateUnoDialog( DialogLibraries.Standard.msgBox_Bitte_warten )
oDialog1.setVisible(true)
oform.ignoreresult = false
oform.reload
goto 100
else
if SQL_Result.getstring(2) > "" then
sIDs = Split(SQL_Result.getstring(2),",")
for i = 0 to ubound (sIDs)
sIDe = TRIM(sIDs(i))
if sIDe = sID then
msgbox "ID schon vorhanden. OK zum suchen des Datensatzes"
DialogLibraries.LoadLibrary("Standard")
oDialog1 = CreateUnoDialog( DialogLibraries.Standard.msgBox_Bitte_warten )
oDialog1.setVisible(true
sID = SQL_Result.getstring (1)
oform.ignoreresult = false
oform.reload
goto 100
endif
next i
endif
endif
wend
exit sub
100:
oform.first
oresult = oform.createresultset
nrow = 1
do
srid = oresult.getstring(3)
if srid = sID then exit do
nrow = nrow + 1
loop while oresult.next
oform.absolute(nrow)
oform.ignoreresult = true
oDialog1.setVisible(false)
msgbox "Datensatz mit ID " +sIDSafe
End Sub
das hilft. Ich hatte schon befürchtet, ich müsste alle Datensätze überarbeiten um nach ,ID, suchen zu können, aber das hier ist viel besser. Vielen Danke
Btw. Ich glaube, du hast vergessen, sID = SQL_Result.getstring (1) zu setzen, um den passenden Datensatz zu suchen.
Wen's interessiert: der fertige Code sieht jetzt so aus:
[code]Sub S_CheckID
oform = thiscomponent.drawpage.Forms.MainForm
oconnection = oform.activeconnection
SQL_Statement = oconnection.createstatement
sSQL = "SELECT ""ID"", ""weitere IDs"" FROM ""Bestand_Videos"""
SQL_Result = SQL_Statement.executequery(sSQL)
otxtID = oform.txtID
sID = otxtID.text
sIDSafe = sID
while SQL_Result.next
if SQL_Result.getstring(1) = sID then' or instr(SQL_Result.getstring(2),sID) > 0 then
sID = SQL_Result.getstring(1)
msgbox "ID schon vorhanden. OK zum suchen des Datensatzes"
DialogLibraries.LoadLibrary("Standard")
oDialog1 = CreateUnoDialog( DialogLibraries.Standard.msgBox_Bitte_warten )
oDialog1.setVisible(true)
oform.ignoreresult = false
oform.reload
goto 100
else
if SQL_Result.getstring(2) > "" then
sIDs = Split(SQL_Result.getstring(2),",")
for i = 0 to ubound (sIDs)
sIDe = TRIM(sIDs(i))
if sIDe = sID then
msgbox "ID schon vorhanden. OK zum suchen des Datensatzes"
DialogLibraries.LoadLibrary("Standard")
oDialog1 = CreateUnoDialog( DialogLibraries.Standard.msgBox_Bitte_warten )
oDialog1.setVisible(true
sID = SQL_Result.getstring (1)
oform.ignoreresult = false
oform.reload
goto 100
endif
next i
endif
endif
wend
exit sub
100:
oform.first
oresult = oform.createresultset
nrow = 1
do
srid = oresult.getstring(3)
if srid = sID then exit do
nrow = nrow + 1
loop while oresult.next
oform.absolute(nrow)
oform.ignoreresult = true
oDialog1.setVisible(false)
msgbox "Datensatz mit ID " +sIDSafe
End Sub[/code]