|
-
Dec 30th, 1999, 03:37 AM
#1
Thread Starter
New Member
I've been trying to make an application that will import an Access Database and give the user a chance to search the database according to a unique id number. I'm using ADO Data control and ADO Datagrid. I have one text box and a command button that performs the operation when it is clicked. So far I've been able to display the whole table in the datagrid but I want to search the records using the id number and display matching results in the datagrid. This has been a problem. I haven't been able to accomplish this. I used the filter property to search the records and I know that it is working because I can display the results to the immediate window; however, that is not very practical not to mention ugly so I want those results put into a grid. I've talked to many different people but have not yet got a correct solution. Some people suggested using an SQL statement to search instead of the filter property and update the data control but I get errors when using their syntax.
HERE is the code I have so far.
Option Explicit
Private Sub cmdclear_Click()
txtuutpart.Text = ""
txtaccpart.Text = ""
txtuutpart.SetFocus
End Sub
*****************************
Private Sub cmdquit_Click()
End
End Sub
*****************************
Private Sub cmdsubmitpart_Click()
Dim struutdata As String
Dim strfield As String
Dim junktwo As Recordset
Dim dbsbart As Database
Dim rstacc As Recordset
Set dbsbart = OpenDatabase("bartacc.mdb")
Set rstacc = dbsbart.OpenRecordset("BartAdtranz", dbOpenDynaset)
struutdata = txtuutpart.Text
Set junktwo = FilterField(rstacc, "UUTPartNumber", struutdata)
End Sub
***********************
Function FilterField(rsttemp As Recordset, strfield As String, strfilter As String) As Recordset
rsttemp.Filter = strfield & "='" & strfilter & "'"
Set FilterField = rsttemp.OpenRecordset
End Function
I would like to find a way to take that FilterField recordset and display it in the grid. Also I'm using VB 6.0 working model edition. ANy assistance is appreciated
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|