03-30-2004, 09:21 AM
Cum Grano Salis
* Guru *
Join Date: Jul 2002
Location: Baltimore, Maryland
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
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"
If strChoice <> "" Then
sSQL = "DELETE * FROM myTable WHERE field1 = '" & strString & "' AND field2 = '" & strChoice & "'"
sSQL = "DELETE * FROM myTable WHERE field1 = '" & strString & "'"
Set cn = Nothing
"Artificial Intelligence is no match for natural stupidity." ~unknown