rprewitt
04-16-2004, 01:46 PM
I have an Access database with two tables. They are linked together with the primary key of one being a relationship field of the second. I have also made a query for this called qTask.
In VB I have a data control (DAO) that have a slew of text boxes and labels linked to it to gather the fields in the record so the user will have more of a user friendly form based app. Now the data control is set up as a dynaset Recordset type because of the need to pull information from both tables with a query statment for a recordsource that sorts out based on a field.
(SELECT * FROM qTask WHERE [CVSP] = "S")
qTask is the query that I made in Access that combines the two tables.cvsp is a field that separated standard from non standard.
Now all the fields are populated and everything works fine. I now need to make a button that allows them to search by task number(primary key of second table) and still populate the fields from both tables. I know that a seek function is the best to use but only useable on a table recordset and i am using a dynaset. I tried to use the findfirst method but it is not working. My code on the Sub click for the search button is as follows:
Private Sub cmdSearch_Click()
Dim strTask As String
strTask = InputBox("Enter the task number that you want to search for")
datCorporate.Recordset.FindFirst "tasknumber = """ & strTask & """"
If datCorporate.Recordset.NoMatch = True Then
MsgBox "No match could be found - - - Try Again"
End If
End Sub
The button is named cmdSearch, the data control is datCorporate, tasknumber is the field name in the access table that I am trying to do the search on. strTask is a variable that I am using to retrieve a string from the user to base the search on.
Any help would be a greatly appreciated.
Thanks in advance
In VB I have a data control (DAO) that have a slew of text boxes and labels linked to it to gather the fields in the record so the user will have more of a user friendly form based app. Now the data control is set up as a dynaset Recordset type because of the need to pull information from both tables with a query statment for a recordsource that sorts out based on a field.
(SELECT * FROM qTask WHERE [CVSP] = "S")
qTask is the query that I made in Access that combines the two tables.cvsp is a field that separated standard from non standard.
Now all the fields are populated and everything works fine. I now need to make a button that allows them to search by task number(primary key of second table) and still populate the fields from both tables. I know that a seek function is the best to use but only useable on a table recordset and i am using a dynaset. I tried to use the findfirst method but it is not working. My code on the Sub click for the search button is as follows:
Private Sub cmdSearch_Click()
Dim strTask As String
strTask = InputBox("Enter the task number that you want to search for")
datCorporate.Recordset.FindFirst "tasknumber = """ & strTask & """"
If datCorporate.Recordset.NoMatch = True Then
MsgBox "No match could be found - - - Try Again"
End If
End Sub
The button is named cmdSearch, the data control is datCorporate, tasknumber is the field name in the access table that I am trying to do the search on. strTask is a variable that I am using to retrieve a string from the user to base the search on.
Any help would be a greatly appreciated.
Thanks in advance