How to change ado record source
Posted on 2002-04-23
I am new to VB and don't know how to handle
the following problem.
I have an access 2000 mdb file and am trying to
create a front end with vb6
I've made the controls on the form as unbound.
There is a txtSearch field on the form. When the
form is loaded, the user has to fill in this
txtSearch field with some Number (71001 etc).
Now my question is how to change the ado Record
Source to select only the records matching the
number entered by the user (in this case 71001)?
For testing, here's the code I am using on the on
click event of a button:
Dim strSql As String
Dim strValue1 As String
strSql = "select * from Expenses WHERE DeptId = txtDeptID"
adoData.RecordSource = strSql
BindControls 'Function to bind controls
The above code does not give me any error message,
but returns records for all depts.
Thanks in advance.