Hi,
I
have an Access database which I've managed to link up to my VB.net
application, and I can view whole tables, edit the data within it etc
just fine.
However, I would like to filter one of my Tableviews
to show only the rows where the value in the UserID column is equal to
the User logged into my application.
The form this Tableview will be on has access to the current user that is logged on by:
Public thisuser As String
with that string being passed from a previous form.
From browsing these forums it seems I need something like this to filter my view:
BindingSource.Filter = String.Format(columnName, variable) or
BindingSource.Filter = String.Format(Me.RegularDataSet1.LeaveRequest.UserIDColumn, thisuser)
However,
no matter what alterations I seem to make to this, I either throw up
various Exception Errors, or end up with a blank view and no data at
all.
Am I on the right track, or barking up totally the wrong tree
Any advice appreciated.
Thanks.

BindingSource.Filter help please
JLBetsch
BindingSource.Filter = "UserID='" & thisuser & "'"
Produces 2 results
While:
BindingSource.Filter = "UserID='" & thisuser & "'"
BindingSource.Filter = "DaysUsed='2'"
Narrows it down to one.
So the answer seems to be, yes.
Sergio VB
hi,
filter property just accept string so you have to put them all in string
MybindingSource.Filter = "ColumnName = value"
so in your case it will be something like this
dim currentuserID as integer
'assign a value to currentuserID
MybindingSource.Filter = string.format("userID = {0}", currentuser)
hope this helps
Netix Liu
Greg4
you are welcome
Jrt
BindingSource.Filter = "UserID='" & thisuser & "'"
It seems to be working as needed,
thanks for the help.
rksty
Is one able to apply a second filter to a filtered binding source, or must one create a table and then filter on that
Sorry to hijack this previous post.
Dix
Imtiaz
hum...
if i do:
BindingSource.Filter = "UserID='" & thisuser & "'"
BindingSource.Filter = "DaysUsed='2'"
I only get the results for the second filtering. Does any one know why.
In my case, I'd like to use 5 filters or less. User can choose some options from 5 comboboxes that u can fitler by. If user chooses to use all 5 of them it is ok, I just make a filter sentence with all filter options in it. But if he chooses to use less i'd have to do an if or case sentence for every option possible.
It would be cool to get it to work like in the sample above:
BindingSource.Filter = "UserID='" & thisuser & "'"
BindingSource.Filter = "DaysUsed='2'"
than all I'd had to do would be an if sentence before every filtering, where i'd check if any option was selected... something like that:
BindingSource.Filter = "UserID='" & thisuser & "'"
if DaysUsed.text <> nothing then
BindingSource.Filter = "DaysUsed='2'"
endif
and so on...
So is there a way to do 5 or less filterings easyly
Thank you and sorry for the mistakes in my post, I hope you can resolve trough examples what I want to do :)
alanuiuc20
hi,
you can use and in the text instead of spliting it to 2 statments
BindingSource.Filter = "UserID='" & thisuser & "' and DaysUsed='2'"
also you can use wildcard filter to return any record contain that part for example if you search for any rowwhere useranme starts with i you can use
BindingSource.Filter = "UserName Like 'c%'"
hope this helps
lowjoel
You are going to have to do some coding but this should work...
Start off by creating Filter Strings for each option/checkbox...
Next create Boolean variable for each checkbox option...
Now you do your optionCheckboxCheckedChanged Event and set your boolean to correspond
Now you put this implementaion in the OkButtonCLicked Event or whatever trigger you want to use
NOTE: you must have filter = null before generating your FILTER!
filter = null;
if (option1Select){
}
if(option2Select){
}
...
...
...
...
...
// Carry on for the rest of the options changing the option variables.
then after if(option5Select) you can add
BindingSource.Filter = filter;
This should work they way you have explained your problem