Problem referencing variables between forms

P

Pete Beatty

I have been out of the VBA programming for a while and am stumbling on what
should be a simple problem that I NEED HELP with.

I have developed one form that has defined two public variables (rst1 as
dao.recordset and rst2 as dao.recordset).

Using the two variables I retrieve records from both files and compare the
fields. when an error is detected, I open another form which is supposed to
display all of the fields for both records and highlight the differences.

The problem is when I attempt to populate the objects on this new window, I
reference the public variables. This creates an error (e.g. "object
required"). the code I use is
me!object1.value = rst1![field1]

I am at a loss. Please assist.
 
R

Ron Weiner

Pete

Try
forms!YourFormName.rst1!field1
If rst1 is declared as Public in the Declarations section on your form
(Public rst1 as DAO.Recordset) and your form is not a subform on another
form, and field1 is the name of the field returned by the recordset.

If you form is a Subform then the proper syntax would be:

forms!YourParentFormName.NameOfSubFormCONTROL.Form.rst1!field1

Ron W
 
P

Pete Beatty

Thanks

Ron Weiner said:
Pete

Try
forms!YourFormName.rst1!field1
If rst1 is declared as Public in the Declarations section on your form
(Public rst1 as DAO.Recordset) and your form is not a subform on another
form, and field1 is the name of the field returned by the recordset.

If you form is a Subform then the proper syntax would be:

forms!YourParentFormName.NameOfSubFormCONTROL.Form.rst1!field1

Ron W
Pete Beatty said:
I have been out of the VBA programming for a while and am stumbling on what
should be a simple problem that I NEED HELP with.

I have developed one form that has defined two public variables (rst1 as
dao.recordset and rst2 as dao.recordset).

Using the two variables I retrieve records from both files and compare
the
fields. when an error is detected, I open another form which is supposed to
display all of the fields for both records and highlight the differences.

The problem is when I attempt to populate the objects on this new window, I
reference the public variables. This creates an error (e.g. "object
required"). the code I use is
me!object1.value = rst1![field1]

I am at a loss. Please assist.
 

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