Populating form fields (1 Viewer)

Djhilbert

Registered User.
Local time
Today, 08:29
Joined
Dec 26, 2011
Messages
17
Hello everyone

You may have seen another post of mine asking for help on a security login in form. (Thanks for all the Help) However, I am working on another database for the same non-profit. In this database I have two forms that use the same payout form. What I would like to do is populate the Social Security field on the payout form from either the veterans form or the returning veterans form. Note: Not both veterans form or returning veterans form are open at the same time

I placed the code on the (on load) section of the payout form. Here is the code:

[forms]![VETERANS form]![SocialSecurity] or [forms]![RETURNING VETERANS form]=[forms]![PAYOUT form]![SocialSecurity]

Err: Veterans form could not be found.

The reason for this error (I think) is because I went through the returning veterans form. (the veterans form and returning veterans form are not opened at the same time. It's one or the other.

I tried changing the position of the payout form to the front:

code:
[forms]![PAYOUT form]![SocialSecurity]=[forms]![VETERANS form]![SocialSecurity] or [forms]![RETURNING VETERANS form]

with this code the Err: Not an excitable statement (not sure why)

Any ideas that could help me will be greatly appreciated

Thank You Deb
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:29
Joined
Oct 29, 2018
Messages
21,531
Hi Deb. When you use a form reference syntax like that, i.e. Forms!FormName, the form has to be open (but may not be visible or hidden) for the reference to work.


By the way, I would be careful with storing SSNs in an Access database because Access is not a secured application/database, so there's a potential for a breach that could lead to identity theft.
 

plog

Banishment Pending
Local time
Today, 10:29
Joined
May 11, 2011
Messages
11,668
the veterans form and returning veterans form are not opened at the same time.

You can't reference something that doesn't exist. So either...

1. Close the form after you do the comparison. Or...

2. Before closing the form, grab the data you need and put it in a variable, then do the comparison with the variable.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:29
Joined
May 21, 2018
Messages
8,581
You would need to check if one or both of the forms are loaded. Do your self a big favor and get rid of all spaces in names. Then you can do away with [] except in expressions.


Code:
If CurrentProject.AllForms("VETERANS form").IsLoaded then
 forms![PAYOUT form].SocialSecurity = forms![VETERANS form].SocialSecurity 
elseIf CurrentProject.AllForms("RETURNING VETERANS form").IsLoaded
  forms![PAYOUT form].SocialSecurity = forms![RETURNING VETERANS form].SocialSecurity
end if

if the form calling this is Pay Out then

Code:
If CurrentProject.AllForms("VETERANS form").IsLoaded then
 Me.SocialSecurity = forms![VETERANS form].SocialSecurity 
elseIf CurrentProject.AllForms("RETURNING VETERANS form").IsLoaded
  me.SocialSecurity = forms![RETURNING VETERANS form].SocialSecurity
end if

However I agree this is unlikely the best design. The calling form should be pushed the value not call back for a value.
 

Users who are viewing this thread

Top Bottom