0
votes

I have a form bound to a table of "header products", with product code and description. On a subform I also display "child products" which are linked to the header products by a common header product code.

When I double click on the product code I open a new form which easily allows the adding of child products to this header product. The user selects a child product from a combo (child products are already in existence) and clicks an "add" button.

It all works really well, except when I refresh my header form from the new form like this:

Forms![RM Edit Header Products].Refresh

Then it moves the header records back to the start, and I need the header records record position to stay where it was.

So after refresh I try:

Forms![RM Edit Header Products].SetFocus
DoCmd.GoToRecord , , acGoTo, gRecNo 

with no effect, perhaps this is just moving on the new form?

And this:

DoCmd.GoToRecord , Forms![RM Edit Header Products], acGoTo, gRecNo

which gives me the eternal error "An expression you entered is the wrong data type for one of the arguments"

Help! this is driving me mad. Can you control the record position in an open form from the code in another open form? This is basically all I need to do.

1

1 Answers

0
votes

You can use:

DoCmd.SelectObject acForm, "RM Edit Header Products"
DoCmd.SearchForRecord, , , "ID = " & searchId & ""

where searchId is the ID you wish to locate.