
03-30-2004, 09:21 AM
|
 |
Cum Grano Salis
Retired Moderator * Guru *
|
|
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
|
|
This is very raw...you need to build your own robust function.Just an example of how this *could* work. You need to handle how this query is really built, all your ADO connection properties and concerns(checking if the connection is already open, validing your records, if you need a recordset object for standard selects, etc.)...I won't do it all for you
Code:
Public Function runSQL(ByVal strString as string, Optional strChoice as String)
Dim sSQL as string
Dim cn as ADODB connection
Set cn = New ADODB.connection
cn.connectionString = "yourConnectionString"
cn.Open
If strChoice <> "" Then
sSQL = "DELETE * FROM myTable WHERE field1 = '" & strString & "' AND field2 = '" & strChoice & "'"
Else
sSQL = "DELETE * FROM myTable WHERE field1 = '" & strString & "'"
End If
cn.execute sSQL
cn.close
Set cn = Nothing
End Function
|
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
|