Supportnet / Forum / Skripte(PHP,ASP,Perl...)
VBA: SQL und Recordset
Frage
Hallo, ich möchte gerne eine Indextabelle überprüfen
0001 Eintrag 1
0002 Eintrag 2 ...
ob ein Eintrag schon vorhanden ist, darauf soll das Programm dann reagieren.
Ich habe es über ein Recordset und SQL Abfragen versucht, habe aber das Problem, dasss ich nicht weiss wie ich eine SQL abfrage durchsuche.
Mein Ansatz:
[code] Dim sql As String
sql = "SELECT (IndexTabelle) From IndexTab Where """ _
& usrMatrix.Cells(4, 1).Value & """"
MsgBox sql
Set adoRecordset = New ADODB.Recordset
With adoRecordset
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockOptimistic
.Open sql, adoConnection, adOpenStatic, adLockOptimistic
If .RecordCount = 0 Then
MsgBox ("0!")
ElseIf .RecordCount = 1 Then
MsgBox ("1!")
End If
.Close
End With
Set adoRecordset = Nothing[/code]
Das Problem ist, dass RecordCount nur nach nem Eintrag sucht, und es Ihm egal ist, was das Value ist. Es soll nur die SQL Abfrage abfragen.Oder direkt danach suchen.
Danke schonmal

