Results 1 to 4 of 4

Thread: Returning two results

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    WALES UK
    Posts
    31
    If I enter a string into a prompt box it returns the result but I need it to return two results:

    IE the name and price in 2 text boxes:

    prompt$ = "Enter the full (complete) Carpet Name."

    SearchStr$ = InputBox(prompt$, "Carpet Search")
    Data1.Recordset.Index = "Carpet Name"
    Data1.Recordset.Seek "=", SearchStr$
    If Data1.Recordset.NoMatch Then
    Data1.Recordset.MoveFirst
    End If

    this code returns the one result is there anyway of modifying this to return to such as the carpet Price into a text box called txtPrice

    Any Ideas?

    cheers good people!

    Rhys

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    don't bother with a datacontrol and and use a proper recordset

    (just a suggestion!)
    Mark
    -------------------

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    WALES UK
    Posts
    31
    how do you mean??

    is your suggestion easier?

    I need the user to enter a name
    ie "CORD" and then if this is in the database it enters it into the text box but I also need it to return the price of cord in another Text Box



  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    this should point you in the right direction

    you'll need a reference to a Microsoft DAO object libriary



    although personally I'd use ADO rather than DAO because DAO is shite but at least it will get you started!

    Code:
    Option Explicit
    Dim db As Database
    Private Sub Command1_Click()
    
    Dim rst As Recordset
    Dim strSQL As String
    srtsql = "SELECT * FROM tablename WHERE CarpetName='" & InputBox(prompt$, "Carpet Search") & "';"
    
    Set rst = db.OpenRecordset(strSQL)
    With rst
      If Not .EOF Then
        Text1 = !CarpetName'or whatever
        Text2 = !price'
      End If
    .Close
    
    End With
    Set rst = Nothing
    
    
    
    
    End Sub
    
    Private Sub Form_Load()
    
    Set db = DAO.OpenDatabase("c:\Carpetdb.mdb")
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    db.Close
    set db = nothing
    End Sub
    Mark
    -------------------

Posting Permissions

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



Click Here to Expand Forum to Full Width