|
-
Apr 11th, 2000, 06:38 PM
#1
Thread Starter
Junior Member
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
-
Apr 11th, 2000, 06:44 PM
#2
Frenzied Member
don't bother with a datacontrol and and use a proper recordset
(just a suggestion!)
-
Apr 11th, 2000, 06:48 PM
#3
Thread Starter
Junior Member
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
-
Apr 11th, 2000, 07:13 PM
#4
Frenzied Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|