Logging the User who created the Order into a Table field called SlsRep.

  • Thread starter Thread starter jalexander via AccessMonster.com
  • Start date Start date
J

jalexander via AccessMonster.com

How do I log the value from my field
[strModifiedBy]
to another field called
[SlsRep]
but only the first time the form is opened?

I'm using this code to grab the Windows user:
---------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
dtmModified = Now
strModifiedBy = Environ("username")
End Sub
---------------------------

But when other users look-up the Order later, the value keeps changing?
I need to move the user who first created the Order to the SlsRep field in my
table.

Any ideas?
Thanks,
cw
 
Hi there. I'm not one of the newsgroup guru's but think I have your answer
if you are setting the value only when the record is first created rather
than when an existing record is edited.

Do the same thing on BeforeInsert. Then it only happens when a new record is
created.
 
Sounds good but i did the following & it did not work:

I added the following code:
-----------------------------------
Private Sub Form_BeforeInsert(Cancel As Integer)
SlsRep = Environ("username")
End Sub
-----------------------------------

I entered in an new Order, printed it off & closed the form,
but when I checked my Table, the SlsRep field was still blank?

As I mentioned before, my BeforeUpdate code works fine & records the user in
my table field called strModifiedBy. But if another user opens the order
later, then the strModifiedBy field changes & I lose the name of the user
who created the Order.

Any other ideas?
Hi there. I'm not one of the newsgroup guru's but think I have your answer
if you are setting the value only when the record is first created rather
than when an existing record is edited.

Do the same thing on BeforeInsert. Then it only happens when a new record is
created.
How do I log the value from my field
[strModifiedBy]
[quoted text clipped - 17 lines]
Thanks,
cw
 
Hi again. Sorry it didn't work for you. That's what happens when someone
unexperienced like me tries to help. I'm still assuming that this is
supposed to happen when a new record is created? I'm not understanding what
you want. I have CurrentUser() automatically populate my new records along
with a date created.

I do it in the forms BeforeInsert event procedure (SlsRep is a field on my
form). I would also have a field [DateCreated].
-----------------------------------
Private Sub Form_BeforeInsert(Cancel As Integer)
Me.SlsRep = CurrentUser()
Me.DateCreated = Now()
End Sub
-----------------------------------
If you're talking about recording edits subsequent to creating a new record,
I'm afraid I'm not much help. I record all edits in separate tables.

HTH and good luck.
--
Bonnie


jalexander via AccessMonster.com said:
Sounds good but i did the following & it did not work:

I added the following code:
-----------------------------------
Private Sub Form_BeforeInsert(Cancel As Integer)
SlsRep = Environ("username")
End Sub
-----------------------------------

I entered in an new Order, printed it off & closed the form,
but when I checked my Table, the SlsRep field was still blank?

As I mentioned before, my BeforeUpdate code works fine & records the user in
my table field called strModifiedBy. But if another user opens the order
later, then the strModifiedBy field changes & I lose the name of the user
who created the Order.

Any other ideas?
Hi there. I'm not one of the newsgroup guru's but think I have your answer
if you are setting the value only when the record is first created rather
than when an existing record is edited.

Do the same thing on BeforeInsert. Then it only happens when a new record is
created.
How do I log the value from my field
[strModifiedBy]
[quoted text clipped - 17 lines]
Thanks,
cw
 
Bonnie, You are a saint.

The BeforeInsert was working all along except I was referencing the wrong
control name.
(I had the Name as Text447)

I changed the name to SlsRep & the code worked perfectly.

SlsRep = Environ("username")

Thanks again,
Anything you need help with with?
ce
Hi again. Sorry it didn't work for you. That's what happens when someone
unexperienced like me tries to help. I'm still assuming that this is
supposed to happen when a new record is created? I'm not understanding what
you want. I have CurrentUser() automatically populate my new records along
with a date created.

I do it in the forms BeforeInsert event procedure (SlsRep is a field on my
form). I would also have a field [DateCreated].
-----------------------------------
Private Sub Form_BeforeInsert(Cancel As Integer)
Me.SlsRep = CurrentUser()
Me.DateCreated = Now()
End Sub
-----------------------------------
If you're talking about recording edits subsequent to creating a new record,
I'm afraid I'm not much help. I record all edits in separate tables.

HTH and good luck.
Sounds good but i did the following & it did not work:
[quoted text clipped - 26 lines]
 
So glad it did work. Nice to be able to help someone in here. Generally, I'm
the one asking for assistance. I love these NewsGroups.
--
Bonnie


jalexander via AccessMonster.com said:
Bonnie, You are a saint.

The BeforeInsert was working all along except I was referencing the wrong
control name.
(I had the Name as Text447)

I changed the name to SlsRep & the code worked perfectly.

SlsRep = Environ("username")

Thanks again,
Anything you need help with with?
ce
Hi again. Sorry it didn't work for you. That's what happens when someone
unexperienced like me tries to help. I'm still assuming that this is
supposed to happen when a new record is created? I'm not understanding what
you want. I have CurrentUser() automatically populate my new records along
with a date created.

I do it in the forms BeforeInsert event procedure (SlsRep is a field on my
form). I would also have a field [DateCreated].
-----------------------------------
Private Sub Form_BeforeInsert(Cancel As Integer)
Me.SlsRep = CurrentUser()
Me.DateCreated = Now()
End Sub
-----------------------------------
If you're talking about recording edits subsequent to creating a new record,
I'm afraid I'm not much help. I record all edits in separate tables.

HTH and good luck.
Sounds good but i did the following & it did not work:
[quoted text clipped - 26 lines]
Thanks,
cw
 
Back
Top