By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,224 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,224 IT Pros & Developers. It's quick & easy.

using Find property in a form to locate records in a table

P: n/a
I am trying to create a data entry form for my database that will
enable a user to add a new record or alter an existing record in the
table all on one form. So far, the form is set up to display the
records of the table in text boxes at the bottom, and I can scroll
thru the records, and a button("Add A New Patient") will allow the
user to go to the end of the table and enter data. The other button
("Find A Patient") has been more difficult...here is the code I have
so far:

Private Sub Command42_Click()
Dim rs As Object
Set rs = Me.Recordset

rs.Filter = "[LastName] = '" & (Me!Text38) & "' and [FacilityCode] =
'" & (Me!Text40) & "'"

End Sub

I want the user to input the last name and facility code of the
record they are trying to update, and have the form display that
record. The problem is that when I run this, the record I want does
not show up in the text boxes at the bottom of the form.
Can anybody help a beginner with this?
Thanks!

Christine
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Christine wrote:
Private Sub Command42_Click()
Dim rs As Object
Set rs = Me.Recordset

rs.Filter = "[LastName] = '" & (Me!Text38) & "' and [FacilityCode] =
'" & (Me!Text40) & "'"

End Sub

The problem is that when I run this, the record I want does
not show up in the text boxes at the bottom of the form.


What happens if you use Me.Filter instead of rs.Filter? Don't forget to
do Me.Filteron = True (that helps)

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #2

P: n/a
Off the top of my head, maybe this will work?

Private Sub Command42_Click()
Dim rs As Recordset

Set rs = Me.RecordsetClone
rs.FindFirst "[LastName] = '" & (Me!Text38) & "' and [FacilityCode] = '" &
(Me!Text40) & "'"
If rs.NoMatch = False Then
Me.BookMark = rs.BookMark
Else
MsgBox "Entry not found"
End IF

End Sub

Mike Storr
www.veraccess.com

"Christine" <cb******@rehabmanagement.com> wrote in message
news:39**************************@posting.google.c om...
I am trying to create a data entry form for my database that will
enable a user to add a new record or alter an existing record in the
table all on one form. So far, the form is set up to display the
records of the table in text boxes at the bottom, and I can scroll
thru the records, and a button("Add A New Patient") will allow the
user to go to the end of the table and enter data. The other button
("Find A Patient") has been more difficult...here is the code I have
so far:

Private Sub Command42_Click()
Dim rs As Object
Set rs = Me.Recordset

rs.Filter = "[LastName] = '" & (Me!Text38) & "' and [FacilityCode] =
'" & (Me!Text40) & "'"

End Sub

I want the user to input the last name and facility code of the
record they are trying to update, and have the form display that
record. The problem is that when I run this, the record I want does
not show up in the text boxes at the bottom of the form.
Can anybody help a beginner with this?
Thanks!

Christine

Nov 12 '05 #3

P: n/a
Mike Storr wrote:
Off the top of my head, maybe this will work?

Private Sub Command42_Click()
Dim rs As Recordset

Set rs = Me.RecordsetClone
rs.FindFirst "[LastName] = '" & (Me!Text38) & "' and [FacilityCode] = '" &
(Me!Text40) & "'"
If rs.NoMatch = False Then
Me.BookMark = rs.BookMark
Else
MsgBox "Entry not found"
End IF

End Sub

Mike Storr
www.veraccess.com


I like that better than whan I suggested; the Filter approach leaves you
with a shrunken dataset (only the record you looked for) and yours only
moves the 'cursor'.

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #4

P: n/a
Thanks. I personnaly hate using filters, like you said they just shrink the
display instead of actually making what you want active. They're ok for
reports, but find them to be a nuissance in forms.
"Bas Cost Budde" <ba*@heuveltop.org> wrote in message
news:c0***********@news2.solcon.nl...
Mike Storr wrote:
Off the top of my head, maybe this will work?

Private Sub Command42_Click()
Dim rs As Recordset

Set rs = Me.RecordsetClone
rs.FindFirst "[LastName] = '" & (Me!Text38) & "' and [FacilityCode] = '" & (Me!Text40) & "'"
If rs.NoMatch = False Then
Me.BookMark = rs.BookMark
Else
MsgBox "Entry not found"
End IF

End Sub

Mike Storr
www.veraccess.com


I like that better than whan I suggested; the Filter approach leaves you
with a shrunken dataset (only the record you looked for) and yours only
moves the 'cursor'.

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.