Here is what I am trying to achieve:
I have an access database with a table [GroupTable] with 3 fields [RecNo, Group, SubGroup] (Group & SubGroup use integers)
I want, under program control, to populate a table adapter with a subset of all records
eg I want to be able to create a table with just those records where Group = 1 or 2 etc
The user will have the ability to select which group is required.
If I write the following SQL code using the Dataset Designer
SELECT RecNo, Group, SubGroup FROM GroupTable
WHERE Group = 1
everything works just fine. There are hundreds of possible values of Group however and 'hard coding' them all is not practical. Hence I want to replace the hard coded "1" in the above example with a variable the value of which the user can determine. This is where the nightmare begins.
According to several references the following code is supposed to work:
SELECT RecNo, Group, SubGroup FROM GroupTable
WHERE Group = @SelectedGroup
where SelectedGroup is a Public Variable the value of which is user determined.
Needless to say this code doesn't work and produces error messages about a required value being missing or of the wrong datatype etc.
Somebody else suggested the call to populate the table adapter should be modified viz:
Me.GroupTableTableAdapter.Fill(Me.UserDataSet.GroupTable, 'SelectedGroup')
However this does not work either and produces error messages to the effect that there are too many paramaters etc. If I remove "SelectedGroup" then it tells me that I don't have enough so I have NO clue what to try next.
From hours and hours of reading about this problem I note that lots of other people have asked the same or fairly similar questions about the same thing but that there aren't a lot of workable replies (if any). I am hoping Daniweb users will be little more forthcoming in that department.
In anticipation .... :)