Andy Lacey
andy at minstersystems.co.uk
Tue Jun 29 16:31:02 CDT 2004
Oleg You've got to embed the value from the vars into the SQL of the select statement, so (I've taken out the superfluous parentheses): Set rs = cn.Execute("SELECT Testing.AttribXrefGrpNumber FROM Testing WHERE Testing.AppsID=" & sAppsID & " AND Testing.EntID=" & sEntID & " AND Testing.AttribID=" & sAttribID) So what you give to the Execute statement is a string which contains the values in your variables. This presupposes that all three id's are numeric. HTH -- Andy Lacey http://www.minstersystems.co.uk > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of > Oleg_123 at xuppa.com > Sent: 29 June 2004 19:21 > To: accessd at databaseadvisors.com > Subject: [AccessD] Select via Recordset > > > there is an error in my select statement how do i make a > field name equal to whats in a textbox ? > > > Dim rs As ADODB.Recordset > Dim cn As Connection > Dim aBOF > Dim aField > Dim sAppsID > Dim sEntID > Dim sAttribID > > sAppsID = txtAppsId > sEntID = txtEntID > sAttribID = txtAttribID > > Set cn = CurrentProject.Connection > > Set rs = cn.Execute("SELECT Testing.AttribXrefGrpNumber FROM > Testing WHERE > (((Testing.AppsID)=sAppsID) AND ((Testing.EntID)=sEntID ) AND > ((Testing.AttribID)=sAttribID))") > aBOF = rs.BOF 'check if string is Empty > If aBOF = True Then > MsgBox "Record Does not exist" > Exit Sub > Else > aField = rs.Fields(0) > MsgBox "Record alredy exists. Group # is " & aField > > End If > > > ----------------------------------------- > Make Money and Find Love at Finally.com > http://www.finally.com/?link=webmail > > > -- > > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/a> ccessd > Website: > http://www.databaseadvisors.com > >