Select row in a datasheet subform

R

Robert

I want to select a row in a datasheet, that is I want to set the focus on a
row in the datasheet. The datasheet is a subform of a main form. Assuming
that I know the value in one of the columns, how would I do this in code? I
would invoke the code from a button on the main form. The value would come
from a textbox on the form. In other words, I need a goto record for a
datasheet which is a subform. Anyone know the coding?

Robert
 
M

Marshall Barton

Robert said:
I want to select a row in a datasheet, that is I want to set the focus on a
row in the datasheet. The datasheet is a subform of a main form. Assuming
that I know the value in one of the columns, how would I do this in code? I
would invoke the code from a button on the main form. The value would come
from a textbox on the form. In other words, I need a goto record for a
datasheet which is a subform.


For a number type field:

With Me.[subform control].Form.RecordsetClone
.FindFirst "[some field]=" & Me.[the text box]
If Not .NoMatch Then
Me.[subform control].Form.Bookmark = .Bookmark
End If
End With

For a Text field, the FindFirst would be:
.FindFirst "[some field]=""" & Me.[the text box] & """"
or for a Date/Time field:
.FindFirst "[some field]=" & Format(Me.[the text box],
"\#yyyy-m-d\#")
 
M

mark cerveno

Robert said:
I want to select a row in a datasheet, that is I want to set the focus on a
row in the datasheet. The datasheet is a subform of a main form. Assuming
that I know the value in one of the columns, how would I do this in code?
I would invoke the code from a button on the main form. The value would
come from a textbox on the form. In other words, I need a goto record for
a datasheet which is a subform. Anyone know the coding?

Robert
 

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