input criteria in textbox of form to find a record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

In form view, find command (Ctrl-F) is available to search records by a
field value. How can I create a form where I just type in the criteria in
the textbox and the record shows up? I have disabled the record
navigation/selection buttons, and I do not want the criteria to auto complete.
Thanks
 
Hello Tracy.

tracy wang said:
In form view, find command (Ctrl-F) is available to search records
by a field value. How can I create a form where I just type in the
criteria in the textbox and the record shows up? I have disabled
the record navigation/selection buttons, and I do not want the
criteria to auto complete.

Place the textbox (txtSearch) in the header of the form, and write a little
"After Update" event ptocedure:

Private Sub txtSearch_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst BuildCriteria("[CustomerID]", dbText, txtSearch)
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Customer not found!", vbExclamation, "Warning"
End If
rs.Close
Set rs = Nothing
End Sub
 
Thanks Wolfgang,
I've tried that, and I think I'm on the right track, but is there any
properties that I have to set my form, in order to make this work? My textbox
is currently unbound, would I still be able to use it as a means of record
naigation?

Wolfgang Kais said:
Hello Tracy.

tracy wang said:
In form view, find command (Ctrl-F) is available to search records
by a field value. How can I create a form where I just type in the
criteria in the textbox and the record shows up? I have disabled
the record navigation/selection buttons, and I do not want the
criteria to auto complete.

Place the textbox (txtSearch) in the header of the form, and write a little
"After Update" event ptocedure:

Private Sub txtSearch_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst BuildCriteria("[CustomerID]", dbText, txtSearch)
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Customer not found!", vbExclamation, "Warning"
End If
rs.Close
Set rs = Nothing
End Sub
 
Hello Tracy.

tracy wang said:
Wolfgang Kais said:
tracy wang said:
In form view, find command (Ctrl-F) is available to search records
by a field value. How can I create a form where I just type in the
criteria in the textbox and the record shows up? I have disabled
the record navigation/selection buttons, and I do not want the
criteria to auto complete.
Place the textbox (txtSearch) in the header of the form, and write a
little "After Update" event procedure:

Private Sub txtSearch_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst BuildCriteria("[CustomerID]", dbText, txtSearch)
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Customer not found!", vbExclamation, "Warning"
End If
rs.Close
Set rs = Nothing
End Sub
Thanks Wolfgang,
I've tried that, and I think I'm on the right track, but is there any
properties that I have to set my form, in order to make this work?
My textbox is currently unbound, would I still be able to use it as
a means of record naigation?

Well, you have to specify the RecordSource auf the form and place
bound controls on the form. The special textbox in the form header
stays unbound. Do you have problems making it work?
 
Thanks Wolfgang.

This is what i did:
1. I created a form with help of the wizard. Form is in single form view.
2. I disabled the navigation buttons and record selector (for security
reasons)
3. I added a textbox in the header, and added the follow vb script to the
form:
Private Sub txtSearch_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst BuildCriteria("[Student ID]", dbText, txtSearch)
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Student not found!", vbExclamation, "Warning"
End If
rs.Close
Set rs = Nothing
End Sub

-should the results show up immediately once I type in the numbers?
-[Student ID] isn't in the form, but the record that matches the Student ID
should show up right?

Thank you for your help again
Regards


Wolfgang Kais said:
Hello Tracy.

tracy wang said:
Wolfgang Kais said:
:
In form view, find command (Ctrl-F) is available to search records
by a field value. How can I create a form where I just type in the
criteria in the textbox and the record shows up? I have disabled
the record navigation/selection buttons, and I do not want the
criteria to auto complete.
Place the textbox (txtSearch) in the header of the form, and write a
little "After Update" event procedure:

Private Sub txtSearch_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst BuildCriteria("[CustomerID]", dbText, txtSearch)
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Customer not found!", vbExclamation, "Warning"
End If
rs.Close
Set rs = Nothing
End Sub
Thanks Wolfgang,
I've tried that, and I think I'm on the right track, but is there any
properties that I have to set my form, in order to make this work?
My textbox is currently unbound, would I still be able to use it as
a means of record naigation?

Well, you have to specify the RecordSource auf the form and place
bound controls on the form. The special textbox in the form header
stays unbound. Do you have problems making it work?
 
Hello Tracy.

tracy wang said:
Thanks Wolfgang.

This is what i did:
1. I created a form with help of the wizard. Form is in single form view.
2. I disabled the navigation buttons and record selector (for security
reasons)
3. I added a textbox in the header, and added the follow vb script to the
form:
Private Sub txtSearch_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst BuildCriteria("[Student ID]", dbText, txtSearch)
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Student not found!", vbExclamation, "Warning"
End If
rs.Close
Set rs = Nothing
End Sub

-should the results show up immediately once I type in the numbers?
-[Student ID] isn't in the form, but the record that matches the Student
ID
should show up right?

The student shoud be displayed after you pressed enter, if the student is
contained in the recordsource of the form.
To test that, manually search for that student.
 
Thanks again Wolfgang,
It still doesn't seem to work for me, I don't know what I'm doing wrong.
regards


Wolfgang Kais said:
Hello Tracy.

tracy wang said:
Thanks Wolfgang.

This is what i did:
1. I created a form with help of the wizard. Form is in single form view.
2. I disabled the navigation buttons and record selector (for security
reasons)
3. I added a textbox in the header, and added the follow vb script to the
form:
Private Sub txtSearch_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst BuildCriteria("[Student ID]", dbText, txtSearch)
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Student not found!", vbExclamation, "Warning"
End If
rs.Close
Set rs = Nothing
End Sub

-should the results show up immediately once I type in the numbers?
-[Student ID] isn't in the form, but the record that matches the Student
ID
should show up right?

The student shoud be displayed after you pressed enter, if the student is
contained in the recordsource of the form.
To test that, manually search for that student.
 
Hello Tracy.

tracy wang said:
Wolfgang Kais said:
tracy wang said:
This is what i did:
1. I created a form with help of the wizard. Form is in single form
view.
2. I disabled the navigation buttons and record selector (for security
reasons)
3. I added a textbox in the header, and added the follow vb script to
the
form:
Private Sub txtSearch_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.FindFirst BuildCriteria("[Student ID]", dbText, txtSearch)
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Student not found!", vbExclamation, "Warning"
End If
rs.Close
Set rs = Nothing
End Sub

-should the results show up immediately once I type in the numbers?
-[Student ID] isn't in the form, but the record that matches the Student
ID
should show up right?
The student shoud be displayed after you pressed enter, if the student is
contained in the recordsource of the form.
To test that, manually search for that student.
Thanks again Wolfgang,
It still doesn't seem to work for me, I don't know what I'm doing wrong.

You could create a combobox in the header of your form using the wizard,
that searches a record based on the selected value.
After that, change the combo box via right-click to a textbox.
 
Back
Top