findrecord in subform

G

Guest

I asked this a few days ago but got no response - possibly I stated the
question in to convoluted a manner.
In any case, the question is - how can I get a combo box to work in a
subform that has the after update code:

DoCmd.GoToControl "Pub Number"
DoCmd.FindRecord Combo9

All I get is the error, "Canot find or replace record at this time."

It works in the subform as a standalone form, but not as a subform.
Form-subform fields are properly linked (master-child).

Any ideas?

jaman57
 
A

Allen Browne

Use FindFirst on the RecordsetClone of the subform.
Test NoMatch to see if the record was found.
If is was, set the form's Bookmark to that of the clone set.

There's an example using that kind of code in this link:
http://allenbrowne.com/ser-03.html

You can use that in a subform, as long as the code goes in the subform's
module. If it goes in the main form's module, replace:
Me
with:
Me.[NameOfYourSubformHere].Form

BTW, the subform shows only those records that match the record in the main
form. If the record you are looking for is not in the subform, you will need
to do some extra work first. Use DLookup() to find the foreign key value.
FindFirst that value in the main form's RecorsetClone. Once you have the
record record in the main form, you can proceed to finding the one you want
in the subform.
 
G

Guest

Than you. I will study this carefully and hopefully will get things working.
I do appreciate your time.

jaman57

Allen Browne said:
Use FindFirst on the RecordsetClone of the subform.
Test NoMatch to see if the record was found.
If is was, set the form's Bookmark to that of the clone set.

There's an example using that kind of code in this link:
http://allenbrowne.com/ser-03.html

You can use that in a subform, as long as the code goes in the subform's
module. If it goes in the main form's module, replace:
Me
with:
Me.[NameOfYourSubformHere].Form

BTW, the subform shows only those records that match the record in the main
form. If the record you are looking for is not in the subform, you will need
to do some extra work first. Use DLookup() to find the foreign key value.
FindFirst that value in the main form's RecorsetClone. Once you have the
record record in the main form, you can proceed to finding the one you want
in the subform.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

jaman57 said:
I asked this a few days ago but got no response - possibly I stated the
question in to convoluted a manner.
In any case, the question is - how can I get a combo box to work in a
subform that has the after update code:

DoCmd.GoToControl "Pub Number"
DoCmd.FindRecord Combo9

All I get is the error, "Canot find or replace record at this time."

It works in the subform as a standalone form, but not as a subform.
Form-subform fields are properly linked (master-child).

Any ideas?

jaman57
 

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