How do you reference a field from a query in a forms?

  • Thread starter Ivan R via AccessMonster.com
  • Start date
I

Ivan R via AccessMonster.com

I have a form and a subform. The form is main form with a subform main.
subform. There are two fields on the main form that get added to the subform
after they are updated, they are Address and Apt. I have an append query
which will add the Address and Apt fields to the subform if they are not
equal to the Last Address or Last Apt of the subform. The Last Address and
Last Apt are obtained from another query which determines which Address/Apt
are the last ones for the specified "client". I have a form based on this
last Address/Apt query so that i can compare the data and determine if they
need to be updated or not on the subform. i have done this with the following
code:

if address <> forms!main!subform!address then
[do the append query]
else
close and exit sub

The problem occurrs when the forms!main!subform!address is empty or null it
causes an error because there is nothing to compare to. How can I work
around this problem? Would it be better to continue to do what I am doing
with the additional form or is there a way to reference a query field in code
like the above reference to the field?

I have tried to create if then statements for "" and null and they also give
errors saying that it is not valid.

Any help would be appreciated.

Thanks in advance
 
F

FSt1

hi,
this is a required field problem. number of way to handle this. here's one

At the start of your code.....
if IsNull(forms!main!subform!address ) then
Msgbox("Enter something in the address box.")
exit sub
end if

If you don't have something th ethe address box then you get a reminder
message and it kills the code untill you do enter something in the address
box.


Regards
FSt1
 

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