PC Pals Forum
Technical Help & Discussion => Website Design & Programming => Topic started by: davypipes on March 11, 2005, 15:02
-
hi guys....
i want to filter a record based on the first 3 values ... using the .filter method
With dataenv.rssale
.Filter = "name_field= '" & "da" & "'"
end with
in that a name like david,or daniel will be in the results.the above code will only bring results based on finding exactly "da" and not a value like "david"
anyone?
:(
-
A Job for Sam, me thinks! Hold on Davy, I'm sure he'll be around at some point soon. :)
-
maybe it is... expect for the fact that i know absolutely no visual basic!!!
ill have a quick think though
-
explain to me what you exactly want to do, sorry am a littel confused from what you are saying. it could just be that I am tired (have been analysing data for 6 hours straight now!).
I am also unsure about the functions you use. Since I dont know vb I can go about this in another way and see if i can piece things together. any explanation will be appreciated.
Oh why dont you try this MSDN page.
-
hey thanks sam...
illl check out the link youve given me. basically i wanted to filter records based on the first characters...eg..all the names starting with "s" but you see in vb i dont no how to do that with the filter method
( .Filter = "field= '" & "argument" & "'")
hopefully i will get some leeds and post the solution :D
-
umm
hopefully u will
with FORTRAN hat on...yes i know old but its fast and thats what I use for my research. In FORTRAN you can read in say the first word of an arugment and then just do a do loop until you get the right input? is this not possible in vb?
sam
-
EUREKA!! :idea: I GOT IT ..ok rather i found a way around it!!!
ok so this is what i decided to do ...
i declared a new recordset and made a string variable where i can put sql code as follows:
Dim pstrSQL As String
Dim rs As New ADODB.Recordset
pstrSQL = "SELECT name FROM sale where firstname like'" & "da" & "___'"
'the ___ portion represents the rest of the characters ie: the above code will bring anything starting with "da" +______ any other characters"
'then in this line of code i get the recordset based on the sql statement
rs.Open pstrSQL, cn, adOpenStatic, adLockOptimistic
'then display the records on a datagrid
Set DataGrid1.DataSource = rs
now all thats remaining is to take that filtered data and copy it to a different table! :cry: now how do i do that!!??? arghhhh anyone good at sql? sam? :(
-
your select statement will surely have set the data to that array, you did read out your results to an array didnt you? if so surely then it is just a process of reading out this array (or datagrid whatever it is) to a file - say a tabulated text file, does this make sense?
-
emmm...array? well i didnt use any array ! i kinda thought :blush: that theres a way i can do it in sql...with just a simple statement! :?
-
the output of your sql query is just your result. this result is surely your table?