Sad Der
accessd666 at yahoo.com
Fri Sep 19 01:19:50 CDT 2003
Hi group, for the last 1,5 hour I'm trying to create an ADO recordset.... What the hell is wrong with the code below? I use a function called GetStatus to run a query and send me the results back...shouldn't be that complex?! When I call it like this: gstrSwitchStatus = GetStatus("qrySwitchStatus") I keep getting the error: Invalid SQL-statement; expected DELETE, INSERT, PROCEDURE, SELECT, or UPDATE. Or when I call it like: (this is the sql-code of the query!) strSQL = "SELECT [tblSource].[Status] AS qryStatus " & _ "FROM tblSource " & _ "WHERE [tblSource].[ID]=[Forms]![fInterface]![lblID].Caption;" gstrSwitchStatus = GetStatus(strSQL) I get the error: No value given for one or more required parameters I call the function as follows: ...and here is the function: Public Function GetStatus(qryName As String) As String Dim strRtn As String Dim conn As ADODB.Connection 'db connection Dim rst As ADODB.Recordset ' On Error GoTo GetCount_ERR strRtn = "FAILED" Set conn = CurrentProject.Connection Set rst = New ADODB.Recordset With rst .ActiveConnection = conn .Source = qryName .LockType = adLockOptimistic .CursorType = adOpenDynamic .Open End With ' rst.Open qryName, conn, adOpenStatic, adLockReadOnly ... ... PLEASE HELP ME OUT! TIA SD __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com