Find specific record in subform

M

Michaelk

I have 2 subforms on the MainForm.
First subform - Control name StList with the form AllStores inside.
Controls on the form StNo and StName (store number and name).
Second subform - Control name GrpList with form GrpStores inside.
Same controls on the second form StNo and StName .
Both subforms in datasheet view.

When I double click on the StName of AllStores subform it adds the record
in the group stores table, refresh the form and this store appeares in the
group list.

So I need to set focus on the record with just added store in the group
list.

This is what I do afte run query to add the record.

Dim mform As Form
Dim sform As Form
Dim stnamevalue

stnamevalue = "NewGrpStorename"

Set mform = Forms!MainForm
mform.Refresh 'after main form refreshed it poits to
the first record on group subform
' in the StNo field
Set sform = mform!GrpList.Form
sform.SetFocus

I was trying DoCmd.FindFirst and also was trying to set sform.RecordsetClone
and do FindFirst on recordset. Seems doing something wrong.

Anyway what is the proper way to to find stnamevalue on the sform?

Regards,
Michael
 
S

strive4peace

Hi Michael,

you can do this in the code behind the AllStores subform


'~~~~~~~~~~~~~~~~

if isnull(Me.StNo_controlname) then exit sub

'if StNo is not a text field, remove the delimiters
me.parent.GrpList.form.RecordsetClone.FindFirst _
"StNo= '" & me.StNo & "'"

If Not me.parent.GrpList.form.RecordsetClone.NoMatch Then
me.parent.GrpList.form.Bookmark = _
me.parent.GrpList.form.RecordsetClone.Bookmark
End If

'~~~~~~~~~~~~~~~~


Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote programming and Training
strive4peace2006 at yahoo.com
*
 

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