Create a default feild

  • Thread starter Create a default feild
  • Start date
C

Create a default feild

Good day my question is
how can you create a default feild for you to determine which user entered
that line of information

Any assistance would be greatly appreciated

Kumar
 
D

Douglas J. Steele

Add a CreatedBy text field to the table, then put code in the form's
BeforeUpdate event to populate that field for new records.

If you're using Access User-Level Security, so that each user has to log
into the application, your code would be something like:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Me!CreatedBy = CurrentUser()

End Sub

If you're not using Access ULS, add the code from
http://www.mvps.org/access/api/api0008.htm at "The Access Web" to your
application, and then use


Private Sub Form_BeforeUpdate(Cancel As Integer)

Me!CreatedBy = fOSUserName()

End Sub
 
C

Create a default feild

Good day Douglas J. Steele
The solution you give me would only give the name of the currently user. i
would like for every time a different user enter a line of information, their
individual username will be as a feild to that line.

For instance if i enter a line of information in the user name feild my User
name will Default and save.
and when you enter a line you username will default and save.

This will mean that as the administrator I can determine which line of
information was entered by whom.


Thank you for your assistance.

Kumar
 
D

Douglas J. Steele

Since each user should be running their own copy of the front-end, that's
exactly what the code I gave you will do.
 
D

Douglas J. Steele

If you're referring to the original question "how can you create a default
feild for you to determine which user
entered that line of information" or "For instance if i enter a line of
information in the user name feild my User name will Default and save. and
when you enter a line you username will default and save.", I've already
answered that question.

What part of the explanation don't you understand?
 
C

Create a default feild

I dont understand where excatly do i have to enter the code in access and
what code do i have to use.
 
D

Douglas J. Steele

Open your form and look at the Properties window. Find the BeforeUpdate
property for the Form object. Set the property to [Event Procedure], then
click on the ellipsis (...) to the right of the property. That will take you
into the VB Editor, in the middle of something that looks like:

Private Sub Form_BeforeUpdate(Cancel As Integer)


End Sub

If you're using Access User-Level Security, you'd type Me!CreatedBy =
CurrentUser() between those two lines.

If you're not using Access User-Level Security, you'd type Me!CreatedBy =
fOSUserName() between those two lines.

If you're not using Access User-Level Security, you also have to create a
new module (not a class module nor a module associated with a form or
report) and copy the code from http://www.mvps.org/access/api/api0008.htm
into that module.

This assumes that you've added a text field named CreatedBy to your table,
and that the RecordSource for the form includes that new field. (In other
words, if you're using a query as the RecordSource, you need to ensure that
the query includes the field. If you're using the table as the RecordSource,
you should be fine)
 
C

Create a default feild

THANK YOU VERY MUCH FOR YOUR ASSISTANCE. I DID IT AND WORK PERFECTLY THANK
YOU!!!!

Douglas J. Steele said:
Open your form and look at the Properties window. Find the BeforeUpdate
property for the Form object. Set the property to [Event Procedure], then
click on the ellipsis (...) to the right of the property. That will take you
into the VB Editor, in the middle of something that looks like:

Private Sub Form_BeforeUpdate(Cancel As Integer)


End Sub

If you're using Access User-Level Security, you'd type Me!CreatedBy =
CurrentUser() between those two lines.

If you're not using Access User-Level Security, you'd type Me!CreatedBy =
fOSUserName() between those two lines.

If you're not using Access User-Level Security, you also have to create a
new module (not a class module nor a module associated with a form or
report) and copy the code from http://www.mvps.org/access/api/api0008.htm
into that module.

This assumes that you've added a text field named CreatedBy to your table,
and that the RecordSource for the form includes that new field. (In other
words, if you're using a query as the RecordSource, you need to ensure that
the query includes the field. If you're using the table as the RecordSource,
you should be fine)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Create a default feild said:
I dont understand where excatly do i have to enter the code in access and
what code do i have to use.
 
G

Guest

999
Create a default feild said:
THANK YOU VERY MUCH FOR YOUR ASSISTANCE. I DID IT AND WORK PERFECTLY THANK
YOU!!!!

Douglas J. Steele said:
Open your form and look at the Properties window. Find the BeforeUpdate
property for the Form object. Set the property to [Event Procedure], then
click on the ellipsis (...) to the right of the property. That will take
you
into the VB Editor, in the middle of something that looks like:

Private Sub Form_BeforeUpdate(Cancel As Integer)


End Sub

If you're using Access User-Level Security, you'd type Me!CreatedBy =
CurrentUser() between those two lines.

If you're not using Access User-Level Security, you'd type Me!CreatedBy =
fOSUserName() between those two lines.

If you're not using Access User-Level Security, you also have to create a
new module (not a class module nor a module associated with a form or
report) and copy the code from http://www.mvps.org/access/api/api0008.htm
into that module.

This assumes that you've added a text field named CreatedBy to your
table,
and that the RecordSource for the form includes that new field. (In other
words, if you're using a query as the RecordSource, you need to ensure
that
the query includes the field. If you're using the table as the
RecordSource,
you should be fine)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Create a default feild" <[email protected]>
wrote in message
I dont understand where excatly do i have to enter the code in access
and
what code do i have to use.





:

If you're referring to the original question "how can you create a
default
feild for you to determine which user
entered that line of information" or "For instance if i enter a line
of
information in the user name feild my User name will Default and save.
and
when you enter a line you username will default and save.", I've
already
answered that question.

What part of the explanation don't you understand?


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Create a default feild"
<[email protected]>
wrote in message
To the question i ask below.

:

A step by step procedure of what?

If you're asking how to split an application into a front-end and
back-end,
see what Tony Toews has at
http://www.granite.ab.ca/access/splitapp/index.htm


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Create a default feild"
<[email protected]>
wrote in message
Can you go please give me a step by step procedure for access
2003.



:

Since each user should be running their own copy of the
front-end,
that's
exactly what the code I gave you will do.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Create a default feild"
<[email protected]>
wrote in message
Good day Douglas J. Steele
The solution you give me would only give the name of the
currently
user. i
would like for every time a different user enter a line of
information,
their
individual username will be as a feild to that line.

For instance if i enter a line of information in the user name
feild
my
User
name will Default and save.
and when you enter a line you username will default and save.

This will mean that as the administrator I can determine which
line
of
information was entered by whom.


Thank you for your assistance.

Kumar

:

Add a CreatedBy text field to the table, then put code in the
form's
BeforeUpdate event to populate that field for new records.

If you're using Access User-Level Security, so that each user
has
to
log
into the application, your code would be something like:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Me!CreatedBy = CurrentUser()

End Sub

If you're not using Access ULS, add the code from
http://www.mvps.org/access/api/api0008.htm at "The Access
Web"
to
your
application, and then use


Private Sub Form_BeforeUpdate(Cancel As Integer)

Me!CreatedBy = fOSUserName()

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Create a default feild" <Create a default
(e-mail address removed)>
wrote in message
Good day my question is
how can you create a default feild for you to determine
which
user
entered
that line of information

Any assistance would be greatly appreciated

Kumar
 

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