MartyConnelly
martyconnelly at shaw.ca
Tue Jun 29 16:57:47 CDT 2004
Try these changes
Option Explicit
Private Sub Command0_Click()
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection 'need full definition
Dim aField As String
Dim sAppsID As String
Dim sEntID As String
Dim sAttribID As String
Dim strSQL As String
sAppsID = txtAppsId.Value 'or Me.txtAppsId.value
sEntID = txtEntID.Value
sAttribID = txtAttribID.Value
strSQL = "SELECT Testing.AttribXrefGrpNumber FROM Testing WHERE " & _
"(((Testing.AppsID)=sAppsID) AND ((Testing.EntID)=sEntID ) AND " & _
"((Testing.AttribID)=sAttribID))"
'display SQL string here
Debug.Print strSQL
Set cn = CurrentProject.Connection
Set rs = cn.Execute(strSQL)
If rs.BOF And rs.EOF Then 'check if recordset is Empty
MsgBox "Record Does not exist"
Debug.Print rs.RecordCount
Exit Sub
Else
aField = rs.Fields(0)
MsgBox "Record alredy exists. Group # is " & aField
End If
End Sub
Oleg_123 at xuppa.com wrote:
>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
>
>
>
>
--
Marty Connelly
Victoria, B.C.
Canada