[AccessD] Select via Recordset

Heenan, Lambert Lambert.Heenan at AIG.com
Tue Jun 29 16:32:50 CDT 2004


I'm guessing that as you are using an "s" prefix that the fields in your
criteria is/are string types. In which case you need to change the select
statement like this...

Set rs = cn.Execute("SELECT Testing.AttribXrefGrpNumber FROM Testing WHERE
(((Testing.AppsID)='" & sAppsID & "'") AND ((Testing.EntID)='" & sEntID &
"'" ) AND
((Testing.AttribID)='" & sAttribID & "'"))")

But this IS A GUESS. We really need to know the data types of your fields to
be sure what's going on.

But then again your problem may stem from the fact that you have not
declared the types of most of your variables. As a result they are all
Variants. 

Also this code is not needed...

sAppsID = txtAppsId
sEntID = txtEntID
sAttribID = txtAttribID

as you can use the name of the text controls directly. So you don't need the
sAppsID, sEntID  and sAttribID  variables at all. You should be able to
write...

Set rs = cn.Execute("SELECT Testing.AttribXrefGrpNumber FROM Testing WHERE
(((Testing.AppsID)='" & txtAppsId & "'") AND ((Testing.EntID)='" & txtEntID
& "'" ) AND
((Testing.AttribID)='" & txtAttribID & "'"))")

And this line...

aField = rs.Fields(0)

should be changed to 

aField = rs!AttribXrefGrpNumber 

to make it more readable and less dependant on the ordinal number of the
recordset's fields.

Give us some more details.

Lambert

> -----Original Message-----
> From:	Oleg_123 at xuppa.com [SMTP:Oleg_123 at xuppa.com]
> Sent:	Tuesday, June 29, 2004 2:21 PM
> 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/accessd
> Website: http://www.databaseadvisors.com



More information about the AccessD mailing list