Click to See Complete Forum and Search --> : Many problems (Sql Statements)
chongo 2002
Sep 30th, 2000, 04:54 PM
How do I get the results of a query to show in text boxes? The query works and shows the results but it also adds all the other fields in the database after the matches. I only want matches to show.
'sql statement
with db
Set rs3 = db1.OpenRecordset("SELECT * " & "FROM [entered] WHERE [RiderNumber] = '" & listry.List(I) & "'", dbOpenDynaset)
With rs3
.edit
txtname = ![RiderName]
txtnumber = ![RiderNumber]
txtother = ![other]
end with
end with
Also How do you use the .findfirst method for numbers? If I use a number field it says data type conversion error.
;) Hope someone can help.
[Edited by chongo 2002 on 09-30-2000 at 08:35 PM]
xmin
Sep 30th, 2000, 09:36 PM
Perhaps you can try this to show the fields in your Textboxes without adding anything to your database (Don¡¯t use .Edit or .AddNew or .Update or anything like those BEFORE you show the fields content.Use them ONLY when you want to add or modify something in the database.).
Code:
____________________________________________________________
With rs3
txtname = !RiderName
txtnumber = !RiderNumber
txtother = !other
End With
____________________________________________________________
You could try using .FindFirst in this way to locate numbers:
Code:
____________________________________________________________
¡®Suppose your RiderNumber field is a Byte field
.FindFirst ¡°RiderNumber = ¡° & Cbyte(105)
¡®Suppose your RiderNumber field is an Integer field
.FindFirst ¡°RiderNumber = ¡° & Cint(105)
¡®And so on
____________________________________________________________
By the way, did you actually use those square brackets in your code? Try deleting them.
___________________________________________________________
Visual Basic Professional 6.0
[Edited by xmin on 09-30-2000 at 10:46 PM]
chongo 2002
Oct 1st, 2000, 08:09 PM
The .findfirst method doesn't matter I want to use sql. But the numbers don't work in the sql query either. Data type conversion error.
And no I didn't use the brackets in my code I forgot to remove them, but they don't hurt anything.
xmin
Oct 2nd, 2000, 02:27 AM
Ahhhh, I didn¡¯t seem to get your message. I see where you went now.
If your "RiderNumer" field is a numeric (i.e., Byte, Integer, Long, etc.) one, try to use the SQL statement in this way:
Code:
____________________________________________________________
Set rs3 = db1.OpenRecordset("SELECT * " & "FROM [entered] WHERE [RiderNumber] = " & Val(listry.List(I)), dbOpenDynaset)
____________________________________________________________
N.B.: Listed items are strings. So when you said your SQL statement worked that implies that your "RiderNumber" field is a Text field. That is perhaps the reason why you got the error message with numbers in the SQL.
If you still have problems, tell me.
Wish you every success.
____________________________________________________________
Visual Basic Professional 6.0
chongo 2002
Oct 2nd, 2000, 04:20 PM
Thanks got evrything workin Great!!!!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.