Programmatically selecting record in subform

  • Thread starter Jonathan Scott via AccessMonster.com
  • Start date
J

Jonathan Scott via AccessMonster.com

Is it possible to select a record in a subform, programmatically? Finding
which one is selected is the simple part; but how to actually select one?

Jonathan Scott
 
J

Jonathan Scott via AccessMonster.com

I forgot to mention this is on Access97.

Thanks,
Jonathan Scott
 
P

PC Datasheet

Put the following code in the Click event of an appropriate field:
MsgBox "You have selected the record you clicked on"
<Code to process the selected record - use Me!NameOfControlInRecord to
reference the record>
 
J

Jonathan Scott via AccessMonster.com

I am not talking about the processing of a record selected with a mouse click.
I would like to know how to simulate such an event in code.

Jonathan Scott
 
A

Albert D.Kallal

Jonathan Scott via AccessMonster.com said:
Is it possible to select a record in a subform, programmatically? Finding
which one is selected is the simple part; but how to actually select one?

Jonathan Scott

I guess a bit more info is needed here. Do you actualy want to do somting
with that reocrd, or do you want to move the reocrd pointer to a particlar
reocrd?

If there was 6 sub-form reocrds, and you wanted to select the 2 reocrd, then
you could in a buttion on the main form go:

dim f as form

set f = me.MySubFormContorlName.Form

f.ReocrdSetClone.AbsolutePosition = 1

f.bookmark = f.RecordSetClone.BookMark

Do note that absoluteposition is zero based. So, you can move to whatever
reocrd you want in the sub-form....
 
J

Jonathan Scott via AccessMonster.com

Thanks! That seems to do the trick. I am trying to simulate the opposite,
really, where pick a certain record, change it, and see what happens when I
leave that record.

Thanks again!
Jonathan Scott
 
P

PC Datasheet

You have to have some criteria to pick a record. ie, CustomerID = 7, Record
Number 11, etc. Then you can use something like:
Dim Rst As DAO.Recordset
Set Rst = Me.RecordsetClone
With Rst
.FindFirst "[CustomerID] = 7"
Me.BookMark = .Bookmark
End With

At this point you will be on the record where CustomerID = 7
 
Top