Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing values in objects on the main form and subform

Status
Not open for further replies.

JimRich

Programmer
Oct 23, 2000
57
US
I need to compare the values in an object on the main form to an object on the subform. The main form (Donors) has an object called TotalCommitment. The subform (donations) has an object called Total. The following code gives me error message 2450. MSAccess cannot find a form named donations.


If Forms!Donations!Total = Me!TotalCommitment Then
Me!BillMe = False
else
Me!BillMe = True
End If

The spelling is all correct. The forms are open. I suspect that I am missing something simple.

Thanks!

JimRich
 
Referencing subforms is probably best achieved with refering thru the main form. The subform is a control on the main form. Perhaps something like this:

[tt]If Me!Donations.Form!Total = Me!TotalCommitment Then[/tt]

Roy-Vidar
 
Thanks for the tip. However it did not solve my problem. The object Me!Donations.Form!Total gave me no value whatsoever. It was supposed to be $150.00. No error messages.

JimRich
 
First - is there really a value in the Total control of the subform.

Then try debugging. Hit F9 on the first executable line, go back to your form and and run whatever should trigger the event in which this resides (form current?).

This should throw you to the VBE with the breakpoint highlighted (if not, try another event, or just use a button to check). Hover you mouse over the different references, and see if they have any values (or select the complete referense, and hit SHIFT +F9)

Run line by line with F8. If none are detected, try alternate ways of referencing in the immidiate pane (CTRL+G) using:

[tt]?Me!Donations.Form!Total[/tt]
- then hit enter...

Until you find something that works.

- BTW - also check the subform control name, which might differ from the subform name as vieved in the database window - has to be the subform control name, but that should've thrown an error too.

Roy-Vidar
 
$150 is showing on the open form in the subform object. I have been debugging regularly by setting breakpoints and stepping through the code.

I checked and the subform name is correct.

JimRich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top