Referencing a subform in VBA (1 Viewer)

parker1

New member
Local time
Yesterday, 21:29
Joined
Jan 2, 2015
Messages
4
:banghead: on this one so I would appreciate any help.

I'll try and explain my problem as clear as I can. I am working in Access 2007 and win7

I have a main form that is based on a table.Contained in that form are 3 subforms all built on queries from join tables for many - to - many relationships.

This arrangement works fine for adding records manually with good control and no duplicates produced. So I am happy with the way it all works. So Far

Now comes the crunch!

I want to auto populate some of the fields on the main form and the subforms using 'farmed' information from tinterweb. Was doing fine with this and have no problems populating fields on the main form (including comboxes looking up tables with 'NotInList' criteria), populating tables and saving new records with the exception of the subforms.

No Mater what I seem to try I cannot gain reference to the controls on the subforms with VBA

I have tried

Me!subform.form.control
Forms!mainform!subform.form.control

And various other hashes but always get the same error " Access can't find control blah d blah"

I can't even appear to set the focus on the sub through VBA
I am obviously missing something????????

I have spent days searching for an answer to no avail
Can anyone shed some light on this or point me in the right direction please?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 21:29
Joined
Aug 30, 2003
Messages
36,125
Make sure you're using the name of the subform control on the main form, if it's different than the actual name of the form being used as a subform.
 

parker1

New member
Local time
Yesterday, 21:29
Joined
Jan 2, 2015
Messages
4
Make sure you're using the name of the subform control on the main form, if it's different than the actual name of the form being used as a subform.

Thanks for that Paul

Yes I was using the name of the subform control but just can't get it to work:mad:

However, found another way of achieving what I wanted.....

The idea was to get the 'farmed' information and populate a form.
The form being populated is the same form used to manually input a record into the DB
I was looking at it backwards!
Why do I need to populate a form that is usually used for manual input when I can populate the tables directly?

A simple sub looking up tables to check if the information already exists, adding to the tables where necessary and creating the joins using master and child ID's does the job and ensures no duplication at the same time.

Just need to create some error traps on loops and it should be stable and, reasonably, efficient.

I will continue to look at this though because I hate it when I can't figure somat :D But I'll work on it in the background for another day.Meanwhile, current project is coming along a treat.
 

Users who are viewing this thread

Top Bottom