PDA

Click to See Complete Forum and Search --> : Help With SQL


Juillet
Jul 31st, 1999, 01:05 AM
'look this over carefully...I changed some things and names
'some intentional and some not...had to recreate it to
'make sure it worked....adjust the names and things to
'your application
.
.this works...tried...tested...& true....(VB6)
'
'
Dim strSQL As String
Dim strPartNumber As String
Dim filepart As String

strPartNumber = txtpartnumber.Text

strSQL = "SELECT * FROM RptPart WHERE PartNumber = '" & strPartNumber & "'"
Data1.RecordSource = strSQL
Data1.Refresh

With Data1.Recordset
While Not .EOF

filepart = Data1.Recordset!PartNumber
List1.AddItem filepart

.MoveNext
Wend

End With


[This message has been edited by Juillet (edited 07-31-1999).]

paul
Jul 31st, 1999, 11:40 AM
Hi I am trying to use SQL to find a record in a MSAccess databse. I can't seem to get it to work . Here is my code. Thanks in Advance.
Private Sub Command1_Click()
Dim strSQL As String
Dim strPartNumber
With Me.Data1
strSQL = "SELECT * FROM Rtppart" & _
"WHERE (PartNumber = ""& txtPartNumber & "");"
Data1.RecordSource = strSQL
Data1.Refresh
End With
End Sub

stweelman
Nov 6th, 1999, 06:48 AM
I use a lot of DAO and some Data controls try this:
"SELECT [fields you want to retrive] FROM [your table] WHERE [your field] = """ & txtwhatever.Text & """"
The [] must be used if there is a space in the string, all SQL must be in all upercase, the(")quotation marks are critical!!Be sure to use the right number of them at the right places or it will not work.