record in datasheet

S

seeker

I have a form which is in datasheet format and would like to have the record
that is found by docmd.findrecord highlited instead of just arrow to the left
of first column. How would this be done?
 
L

Linq Adams via AccessMonster.com

Two questions:

How are you planning to use DoCmd.FindRecord? You realize that you cannot
have command buttons on a Datashet View form?

What exactly do you want to 'hilight?' What you have in Datasheet View is a
row of connected textboxes. There is, in essence, nothing that will 'hilight'
the row, if that's what you're talking about. If you placed code in the
Form_Current event you could have a particular field receive focus and
hilight that field every time you move to a different record.
 
S

seeker

Thank you i am sorry I should have said subform that is datasheet view. A
text box in primary form is used to develop a search on partial or full last
name of customer. The row that is found needs hilited not just the one field.
It would be as if I clicked on the row to hilite it. Thank you again.
 
K

KenSheridan via AccessMonster.com

Using the FindRecord method, the following code in the parent form's module
should find and highlight a row in the subform in a subform control named
sfcCustomers where the LastName value starts with the string entered in the
text box txtName in the parent form.

Dim frm As Form

Set frm = Me.sfcCustomers.Form

Me.sfcCustomers.SetFocus
frm.LastName.SetFocus
DoCmd.FindRecord Me.txtName, acStart
RunCommand acCmdSelectRecord

Personally I'd not have used the FindRecord method, but instead found the
record in a clone of the subform's recordset and then, if a match exists,
synchronized the bookmarks:

Dim frm As Form
Dim rst As Object

Set frm = Me.sfcCustomers.Form
Set rst = frm.Recordset.Clone

With rst
.FindFirst "Lastname Like """ & Me.txtName & "*"""
If Not .NoMatch Then
frm.Bookmark = rst.Bookmark
Me.sfcCustomers.SetFocus
RunCommand acCmdSelectRecord
End If
End With

Ken Sheridan
Stafford, England
Thank you i am sorry I should have said subform that is datasheet view. A
text box in primary form is used to develop a search on partial or full last
name of customer. The row that is found needs hilited not just the one field.
It would be as if I clicked on the row to hilite it. Thank you again.
Two questions:
[quoted text clipped - 6 lines]
Form_Current event you could have a particular field receive focus and
hilight that field every time you move to a different record.
 
K

KenSheridan via AccessMonster.com

A complete row can be highlighted by means of the acCmdSelectRecord constant
as the command argument of the RunCommand method.

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top