Sponsor for PC Pals Forum

Author Topic: filtering records vb  (Read 3886 times)

Offline davypipes

  • Regular Member
  • **
  • Posts: 31
filtering records vb
« 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?
 :(

Offline Simon

  • Administrator
  • *****
  • Posts: 76533
  • First to score 7/7 in Quiz of The Week's News 2017
filtering records vb
« Reply #1 on: March 11, 2005, 19:43 »
A Job for Sam, me thinks!  Hold on Davy, I'm sure he'll be around at some point soon.   :)
Many thanks to all our members, who have made PC Pals such an outstanding success!   :thumb:

Offline sam

  • Administrator
  • *****
  • Posts: 19966
filtering records vb
« Reply #2 on: March 12, 2005, 01:09 »
maybe it is... expect for the fact that i know absolutely no visual basic!!!

ill have a quick think though
- sam | @starrydude --

Offline sam

  • Administrator
  • *****
  • Posts: 19966
filtering records vb
« Reply #3 on: March 12, 2005, 01:23 »
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.
- sam | @starrydude --

Offline davypipes

  • Regular Member
  • **
  • Posts: 31
filtering records vb
« Reply #4 on: March 12, 2005, 06:23 »
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

Offline sam

  • Administrator
  • *****
  • Posts: 19966
filtering records vb
« Reply #5 on: March 12, 2005, 12:25 »
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
- sam | @starrydude --

Offline davypipes

  • Regular Member
  • **
  • Posts: 31
filtering records vb
« Reply #6 on: March 14, 2005, 09:48 »
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? :(

Offline sam

  • Administrator
  • *****
  • Posts: 19966
filtering records vb
« Reply #7 on: March 14, 2005, 20:51 »
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?
- sam | @starrydude --

Offline davypipes

  • Regular Member
  • **
  • Posts: 31
filtering records vb
« Reply #8 on: March 16, 2005, 13:07 »
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! :?

Offline sam

  • Administrator
  • *****
  • Posts: 19966
filtering records vb
« Reply #9 on: March 16, 2005, 17:01 »
the output of your sql query is just your result. this result is surely your table?
- sam | @starrydude --


Show unread posts since last visit.
Sponsor for PC Pals Forum