Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    27

    Unanswered: 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

  2. #2
    Join Date
    Jun 2004
    Posts
    55
    o.o You forgot the ; at the end of the statement I think and a couple of other things:

    [edit] Gah I missed the second part of the question and I just revised the answer [/edit]

    Set rs = cn.Execute("SELECT [Testing].AttribXrefGrpNumber FROM [Testing] WHERE ((([Testing].[AppsID])=[Forms]![FormName]![txtAppsID]) AND (([Testing].[EntID])=[Forms]![FormName]![txtEntID] ) AND (([Testing].[AttribID])=[Forms]![FormName]![txtAttribID]));")
    Last edited by dwil2g1; 06-29-04 at 15:24.

  3. #3
    Join Date
    Dec 2003
    Posts
    27
    can't i make variables equal to text box values ? thats what i was trying..

    sAppsID = txtAppsId
    sEntID = txtEntID
    sAttribID = txtAttribID

  4. #4
    Join Date
    Jun 2004
    Posts
    55
    Well yeah but then you have to do something like this:

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

    Unless there's another reason you need them as variables I think that you're just adding in extra coding for yourself, since the textboxes are variable already.
    Last edited by dwil2g1; 06-29-04 at 15:43.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •