Default Value from another table

  • Thread starter Thread starter pcstechnical.sfhs
  • Start date Start date
P

pcstechnical.sfhs

I want to assign a value in a form to a value from another table.

I want to be able to do this for many forms (using the same value from
that table).

Why? Well, here is the setup:
I have a login screen in the beginning (has a combo for the usernames,
and text for the passwords). I have another table (table1) the records
what username you selected. I want to use that value, and use it as
the default value for the "Name" fields in forms the individual will
use (that way they don't have to type in their name, and/or have a
combo to select their name (where they can lie and chose someone elses
name)). And I would like to be able to do this for a bunch of
different forms.

Ideas?
P.S. I'm just a beginner, so I'm not very proficient at VB, so if you
use it as your solution, a little explanation of what is doing what
would really help me out. Thanks.
 
You can put a control on each form to store the user name. It can be
invisible and it should have its Tab Stop property set to No.

The use a Dlookup as the Control Source of the control
=DLookup("[User]", "Table")

[User] should be the name of the field where you have the user id and
Table should be the name of the table you said you store the user name in.
 
You can put a control on each form to store the user name. It can be
invisible and it should have its Tab Stop property set to No.

The use a Dlookup as the Control Source of the control
=DLookup("[User]", "Table")

[User] should be the name of the field where you have the user id and
Table should be the name of the table you said you store the user name in.
--
Dave Hargis, Microsoft Access MVP



I want to assign a value in a form to a value from another table.
I want to be able to do this for many forms (using the same value from
that table).
Why? Well, here is the setup:
I have a login screen in the beginning (has a combo for the usernames,
and text for the passwords). I have another table (table1) the records
what username you selected. I want to use that value, and use it as
the default value for the "Name" fields in forms the individual will
use (that way they don't have to type in their name, and/or have a
combo to select their name (where they can lie and chose someone elses
name)). And I would like to be able to do this for a bunch of
different forms.
Ideas?
P.S. I'm just a beginner, so I'm not very proficient at VB, so if you
use it as your solution, a little explanation of what is doing what
would really help me out. Thanks.- Hide quoted text -

- Show quoted text -

Thank you so much! I think it will work.
 
You can put a control on each form to store the user name. It can be
invisible and it should have its Tab Stop property set to No.

The use a Dlookup as the Control Source of the control
=DLookup("[User]", "Table")

[User] should be the name of the field where you have the user id and
Table should be the name of the table you said you store the user name in.
--
Dave Hargis, Microsoft Access MVP



I want to assign a value in a form to a value from another table.
I want to be able to do this for many forms (using the same value from
that table).
Why? Well, here is the setup:
I have a login screen in the beginning (has a combo for the usernames,
and text for the passwords). I have another table (table1) the records
what username you selected. I want to use that value, and use it as
the default value for the "Name" fields in forms the individual will
use (that way they don't have to type in their name, and/or have a
combo to select their name (where they can lie and chose someone elses
name)). And I would like to be able to do this for a bunch of
different forms.
Ideas?
P.S. I'm just a beginner, so I'm not very proficient at VB, so if you
use it as your solution, a little explanation of what is doing what
would really help me out. Thanks.- Hide quoted text -

- Show quoted text -

Another question though: After doing your suggestion, it was showing
the correct values. However, in the new forms that I created (based on
new tables), it wasn't recording that value it was looking up into the
field for the new table. After the dlookup function, do I need to have
something where it still records that value into the field for that
table?
 
I was not aware this was part of the record you are saving.
Move the code from the Control Source property to the Default Value property
and bind the control to the field you want it in.
--
Dave Hargis, Microsoft Access MVP


You can put a control on each form to store the user name. It can be
invisible and it should have its Tab Stop property set to No.

The use a Dlookup as the Control Source of the control
=DLookup("[User]", "Table")

[User] should be the name of the field where you have the user id and
Table should be the name of the table you said you store the user name in.
--
Dave Hargis, Microsoft Access MVP



I want to assign a value in a form to a value from another table.
I want to be able to do this for many forms (using the same value from
that table).
Why? Well, here is the setup:
I have a login screen in the beginning (has a combo for the usernames,
and text for the passwords). I have another table (table1) the records
what username you selected. I want to use that value, and use it as
the default value for the "Name" fields in forms the individual will
use (that way they don't have to type in their name, and/or have a
combo to select their name (where they can lie and chose someone elses
name)). And I would like to be able to do this for a bunch of
different forms.
Ideas?
P.S. I'm just a beginner, so I'm not very proficient at VB, so if you
use it as your solution, a little explanation of what is doing what
would really help me out. Thanks.- Hide quoted text -

- Show quoted text -

Another question though: After doing your suggestion, it was showing
the correct values. However, in the new forms that I created (based on
new tables), it wasn't recording that value it was looking up into the
field for the new table. After the dlookup function, do I need to have
something where it still records that value into the field for that
table?
 
You can put a control on each form to store the user name. It can be
invisible and it should have its Tab Stop property set to No.
The use a Dlookup as the Control Source of the control
=DLookup("[User]", "Table")
[User] should be the name of the field where you have the user id and
Table should be the name of the table you said you store the user name in.
- Show quoted text -

Another question though: After doing your suggestion, it was showing
the correct values. However, in the new forms that I created (based on
new tables), it wasn't recording that value it was looking up into the
field for the new table. After the dlookup function, do I need to have
something where it still records that value into the field for that
table?- Hide quoted text -

- Show quoted text -

Actually, I think I answered my question. I took your suggestion, and
instead of putting that dlookup function as the control source, I put
it as the default value. That seems to be doing what I need it too.

Thanks again for your help.
 
Back
Top