CurrentUser()

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to copy and log each user that uses a DB. I am currently using
currentuser() but all I get is admin as the user. I have tried logging on to
the machine with multiple accounts and still nothing. Any ideas? I want to
give everyone access to the DB without creating a user ID I just want to be
able to see who is using it.
 
Jeff,
Thanks for the help. I inserted the code in a new module and named it
accordingly. To display the name captured, I setup a text box on the main
form with the control source as =fOSUserName() when I start the DB is get the
following in the box #Name? any suggestions?
 
Hi Jeff,
I've used your suggestions from this posting and they work beautifully.
However, I've run into an issue; when someone copies a record

(here's my code for the copy)
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... CreatedBy FROM tbl_MainBarcode_Single_new WHERE ([BarcodeID]
= Forms!frm_Entry_SingleItem.BarcodeID)"

....it copies the userName field as well, I'd like it to pull the current
users network ID for the "new" record they've just created (via copy). Any
guidance as to how I might accomplish this?
 
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... " & Chr(34) & fOSUserName() & Chr(34) & " AS CreatedBy
FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] = " &
Forms!frm_Entry_SingleItem.BarcodeID


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


dl said:
Hi Jeff,
I've used your suggestions from this posting and they work beautifully.
However, I've run into an issue; when someone copies a record

(here's my code for the copy)
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... CreatedBy FROM tbl_MainBarcode_Single_new WHERE ([BarcodeID]
= Forms!frm_Entry_SingleItem.BarcodeID)"

...it copies the userName field as well, I'd like it to pull the current
users network ID for the "new" record they've just created (via copy). Any
guidance as to how I might accomplish this?
--
dl


Jeff Conrad said:
What did you name the module itself?
It cannot be the name of any procedure or function.
Rename the module to something like basUserName.
Compile the code and then retest.

--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:
 
Hi Douglas,
Thank you for the code! I'm now only having one issue, when the "new"
record is created the userName on the "old" record and the "new" record seem
to swtich. So now the original record shows the new userName and the "new"
record shows the old userName.

Can someone tell me what I'm doing wrong?

Here's the code:
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, DeliveryVehicle, DistArea, DistQty, DistStartDate, DistEndDate,
ValidStartDate, ValidEndDate, ValidArea, NoteGeneral, Chain, DateAdded,
Cancelled, PromoCouponName, GroupRequesting, OfferType, Requester,
HurdleType, HurdleNumber, ProgrammedOrNot, RewardsOrNot, " & Chr(34) &
fOSUserName() & Chr(34) & " AS CreatedBy, MoreThan10stores FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] =
Forms!frm_Entry_SingleItem.BarcodeID)"


Thank you!!!
--
dl


Douglas J Steele said:
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... " & Chr(34) & fOSUserName() & Chr(34) & " AS CreatedBy
FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] = " &
Forms!frm_Entry_SingleItem.BarcodeID


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


dl said:
Hi Jeff,
I've used your suggestions from this posting and they work beautifully.
However, I've run into an issue; when someone copies a record

(here's my code for the copy)
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... CreatedBy FROM tbl_MainBarcode_Single_new WHERE ([BarcodeID]
= Forms!frm_Entry_SingleItem.BarcodeID)"

...it copies the userName field as well, I'd like it to pull the current
users network ID for the "new" record they've just created (via copy). Any
guidance as to how I might accomplish this?
--
dl


Jeff Conrad said:
What did you name the module itself?
It cannot be the name of any procedure or function.
Rename the module to something like basUserName.
Compile the code and then retest.

--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:

Jeff,
Thanks for the help. I inserted the code in a new module and named it
accordingly. To display the name captured, I setup a text box on the main
form with the control source as =fOSUserName() when I start the DB is get the
following in the box #Name? any suggestions?
 
How can you tell? What other difference is there between the two rows that
enable you to tell which record is which?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


dl said:
Hi Douglas,
Thank you for the code! I'm now only having one issue, when the "new"
record is created the userName on the "old" record and the "new" record
seem
to swtich. So now the original record shows the new userName and the
"new"
record shows the old userName.

Can someone tell me what I'm doing wrong?

Here's the code:
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, DeliveryVehicle, DistArea, DistQty, DistStartDate,
DistEndDate,
ValidStartDate, ValidEndDate, ValidArea, NoteGeneral, Chain, DateAdded,
Cancelled, PromoCouponName, GroupRequesting, OfferType, Requester,
HurdleType, HurdleNumber, ProgrammedOrNot, RewardsOrNot, " & Chr(34) &
fOSUserName() & Chr(34) & " AS CreatedBy, MoreThan10stores FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] =
Forms!frm_Entry_SingleItem.BarcodeID)"


Thank you!!!
--
dl


Douglas J Steele said:
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... " & Chr(34) & fOSUserName() & Chr(34) & " AS CreatedBy
FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] = " &
Forms!frm_Entry_SingleItem.BarcodeID


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


dl said:
Hi Jeff,
I've used your suggestions from this posting and they work
beautifully.
However, I've run into an issue; when someone copies a record

(here's my code for the copy)
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... CreatedBy FROM tbl_MainBarcode_Single_new WHERE ([BarcodeID]
= Forms!frm_Entry_SingleItem.BarcodeID)"

...it copies the userName field as well, I'd like it to pull the
current
users network ID for the "new" record they've just created (via copy). Any
guidance as to how I might accomplish this?
--
dl


:

What did you name the module itself?
It cannot be the name of any procedure or function.
Rename the module to something like basUserName.
Compile the code and then retest.

--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:

Jeff,
Thanks for the help. I inserted the code in a new module and named
it
accordingly. To display the name captured, I setup a text box on
the main
form with the control source as =fOSUserName() when I start the DB
is get the
following in the box #Name? any suggestions?
 
Well, the form shows the field that stores the UserName, so after hitting the
command button, which runs the SQL, the new (copy) record has the same
UserName as the one I just copied - instead of pulling my UserName and
putting it on the new/copied record. Does that make sense?

So I'm able to see that the UserName doesn't change when a copy is made (the
record I'm copying of course has another person's UserName, so I can see if
it replaces it with mine). To double-check I always look within the table
itself, as well.

thanks for any help you can give!
--
dl


Douglas J. Steele said:
How can you tell? What other difference is there between the two rows that
enable you to tell which record is which?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


dl said:
Hi Douglas,
Thank you for the code! I'm now only having one issue, when the "new"
record is created the userName on the "old" record and the "new" record
seem
to swtich. So now the original record shows the new userName and the
"new"
record shows the old userName.

Can someone tell me what I'm doing wrong?

Here's the code:
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, DeliveryVehicle, DistArea, DistQty, DistStartDate,
DistEndDate,
ValidStartDate, ValidEndDate, ValidArea, NoteGeneral, Chain, DateAdded,
Cancelled, PromoCouponName, GroupRequesting, OfferType, Requester,
HurdleType, HurdleNumber, ProgrammedOrNot, RewardsOrNot, " & Chr(34) &
fOSUserName() & Chr(34) & " AS CreatedBy, MoreThan10stores FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] =
Forms!frm_Entry_SingleItem.BarcodeID)"


Thank you!!!
--
dl


Douglas J Steele said:
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... " & Chr(34) & fOSUserName() & Chr(34) & " AS CreatedBy
FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] = " &
Forms!frm_Entry_SingleItem.BarcodeID


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi Jeff,
I've used your suggestions from this posting and they work
beautifully.
However, I've run into an issue; when someone copies a record

(here's my code for the copy)
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... CreatedBy FROM tbl_MainBarcode_Single_new WHERE
([BarcodeID]
= Forms!frm_Entry_SingleItem.BarcodeID)"

...it copies the userName field as well, I'd like it to pull the
current
users network ID for the "new" record they've just created (via copy).
Any
guidance as to how I might accomplish this?
--
dl


:

What did you name the module itself?
It cannot be the name of any procedure or function.
Rename the module to something like basUserName.
Compile the code and then retest.

--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:

Jeff,
Thanks for the help. I inserted the code in a new module and named
it
accordingly. To display the name captured, I setup a text box on
the
main
form with the control source as =fOSUserName() when I start the DB
is
get the
following in the box #Name? any suggestions?
 
That doesn't make any sense.

Try something along the lines of:

Dim strSQL As String

strSQL = "INSERT INTO tbl_MainBarcode_Single_new " & _
"SELECT BarcodeID, OfferDetail, DeliveryVehicle, " & _
"DistArea, DistQty, DistStartDate, DistEndDate, " & _
"ValidStartDate, ValidEndDate, ValidArea, " & _
"NoteGeneral, Chain, DateAdded, Cancelled, " & _
"PromoCouponName, GroupRequesting, OfferType, " & _
"Requester, HurdleType, HurdleNumber, ProgrammedOrNot, " & _
"RewardsOrNot, " & Chr(34) & fOSUserName() & Chr(34) & _
" AS CreatedBy, MoreThan10stores " & _
"FROM tbl_MainBarcode_Single_new " & _
"WHERE [BarcodeID] = " & Forms!frm_Entry_SingleItem.BarcodeID

Debug.Print strSQL

DoCmd.RunSQL strSQL

Go to the debug window (Ctrl-G) and see what gets written out as the SQL.
Copy that into a query and run it.

If BarcodeID is text, change that last line to

"WHERE [BarcodeID] = " & Chr(34) &
Forms!frm_Entry_SingleItem.BarcodeID & Chr(34)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


dl said:
Well, the form shows the field that stores the UserName, so after hitting the
command button, which runs the SQL, the new (copy) record has the same
UserName as the one I just copied - instead of pulling my UserName and
putting it on the new/copied record. Does that make sense?

So I'm able to see that the UserName doesn't change when a copy is made (the
record I'm copying of course has another person's UserName, so I can see if
it replaces it with mine). To double-check I always look within the table
itself, as well.

thanks for any help you can give!
--
dl


Douglas J. Steele said:
How can you tell? What other difference is there between the two rows that
enable you to tell which record is which?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


dl said:
Hi Douglas,
Thank you for the code! I'm now only having one issue, when the "new"
record is created the userName on the "old" record and the "new" record
seem
to swtich. So now the original record shows the new userName and the
"new"
record shows the old userName.

Can someone tell me what I'm doing wrong?

Here's the code:
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, DeliveryVehicle, DistArea, DistQty, DistStartDate,
DistEndDate,
ValidStartDate, ValidEndDate, ValidArea, NoteGeneral, Chain, DateAdded,
Cancelled, PromoCouponName, GroupRequesting, OfferType, Requester,
HurdleType, HurdleNumber, ProgrammedOrNot, RewardsOrNot, " & Chr(34) &
fOSUserName() & Chr(34) & " AS CreatedBy, MoreThan10stores FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] =
Forms!frm_Entry_SingleItem.BarcodeID)"


Thank you!!!
--
dl


:

DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... " & Chr(34) & fOSUserName() & Chr(34) & " AS CreatedBy
FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] = " &
Forms!frm_Entry_SingleItem.BarcodeID


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi Jeff,
I've used your suggestions from this posting and they work
beautifully.
However, I've run into an issue; when someone copies a record

(here's my code for the copy)
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... CreatedBy FROM tbl_MainBarcode_Single_new WHERE
([BarcodeID]
= Forms!frm_Entry_SingleItem.BarcodeID)"

...it copies the userName field as well, I'd like it to pull the
current
users network ID for the "new" record they've just created (via copy).
Any
guidance as to how I might accomplish this?
--
dl


:

What did you name the module itself?
It cannot be the name of any procedure or function.
Rename the module to something like basUserName.
Compile the code and then retest.

--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:

Jeff,
Thanks for the help. I inserted the code in a new module and named
it
accordingly. To display the name captured, I setup a text box on
the
main
form with the control source as =fOSUserName() when I start the DB
is
get the
following in the box #Name? any suggestions?
 
I haven't had time to implement this today, but I will first thing tomorrow -
then I'll let you know how it goes.

Thanks again!!!
--
dl


Douglas J Steele said:
That doesn't make any sense.

Try something along the lines of:

Dim strSQL As String

strSQL = "INSERT INTO tbl_MainBarcode_Single_new " & _
"SELECT BarcodeID, OfferDetail, DeliveryVehicle, " & _
"DistArea, DistQty, DistStartDate, DistEndDate, " & _
"ValidStartDate, ValidEndDate, ValidArea, " & _
"NoteGeneral, Chain, DateAdded, Cancelled, " & _
"PromoCouponName, GroupRequesting, OfferType, " & _
"Requester, HurdleType, HurdleNumber, ProgrammedOrNot, " & _
"RewardsOrNot, " & Chr(34) & fOSUserName() & Chr(34) & _
" AS CreatedBy, MoreThan10stores " & _
"FROM tbl_MainBarcode_Single_new " & _
"WHERE [BarcodeID] = " & Forms!frm_Entry_SingleItem.BarcodeID

Debug.Print strSQL

DoCmd.RunSQL strSQL

Go to the debug window (Ctrl-G) and see what gets written out as the SQL.
Copy that into a query and run it.

If BarcodeID is text, change that last line to

"WHERE [BarcodeID] = " & Chr(34) &
Forms!frm_Entry_SingleItem.BarcodeID & Chr(34)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


dl said:
Well, the form shows the field that stores the UserName, so after hitting the
command button, which runs the SQL, the new (copy) record has the same
UserName as the one I just copied - instead of pulling my UserName and
putting it on the new/copied record. Does that make sense?

So I'm able to see that the UserName doesn't change when a copy is made (the
record I'm copying of course has another person's UserName, so I can see if
it replaces it with mine). To double-check I always look within the table
itself, as well.

thanks for any help you can give!
--
dl


Douglas J. Steele said:
How can you tell? What other difference is there between the two rows that
enable you to tell which record is which?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hi Douglas,
Thank you for the code! I'm now only having one issue, when the "new"
record is created the userName on the "old" record and the "new" record
seem
to swtich. So now the original record shows the new userName and the
"new"
record shows the old userName.

Can someone tell me what I'm doing wrong?

Here's the code:
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, DeliveryVehicle, DistArea, DistQty, DistStartDate,
DistEndDate,
ValidStartDate, ValidEndDate, ValidArea, NoteGeneral, Chain, DateAdded,
Cancelled, PromoCouponName, GroupRequesting, OfferType, Requester,
HurdleType, HurdleNumber, ProgrammedOrNot, RewardsOrNot, " & Chr(34) &
fOSUserName() & Chr(34) & " AS CreatedBy, MoreThan10stores FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] =
Forms!frm_Entry_SingleItem.BarcodeID)"


Thank you!!!
--
dl


:

DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... " & Chr(34) & fOSUserName() & Chr(34) & " AS CreatedBy
FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] = " &
Forms!frm_Entry_SingleItem.BarcodeID


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi Jeff,
I've used your suggestions from this posting and they work
beautifully.
However, I've run into an issue; when someone copies a record

(here's my code for the copy)
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... CreatedBy FROM tbl_MainBarcode_Single_new WHERE
([BarcodeID]
= Forms!frm_Entry_SingleItem.BarcodeID)"

...it copies the userName field as well, I'd like it to pull the
current
users network ID for the "new" record they've just created (via copy).
Any
guidance as to how I might accomplish this?
--
dl


:

What did you name the module itself?
It cannot be the name of any procedure or function.
Rename the module to something like basUserName.
Compile the code and then retest.

--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:

Jeff,
Thanks for the help. I inserted the code in a new module and named
it
accordingly. To display the name captured, I setup a text box on
the
main
form with the control source as =fOSUserName() when I start the DB
is
get the
following in the box #Name? any suggestions?
 
Hello everyone,
Ok, I've taken the code below (graciously provided by Doug Steele) and
followed the directions given. Here is what was written out as the SQL:

INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID, OfferDetail,
DeliveryVehicle, DistArea, DistQty, DistStartDate, DistEndDate,
ValidStartDate, ValidEndDate, ValidArea, NoteGeneral, Chain, DateAdded,
Cancelled, PromoCouponName, GroupRequesting, OfferType, Requester,
HurdleType, HurdleNumber, ProgrammedOrNot, RewardsOrNot, "dlongton" AS
CreatedBy, MoreThan10stores FROM tbl_MainBarcode_Single_new WHERE [BarcodeID]
= 159010080000000000

When I run the query just by itself it does create a copy and put "dlongton"
into the new record, leaving the UserName in the original record as it was
(which is what I want it to do). However, since this will of course need to
pull various UserNames I'll have to use the "fOSUserName()" to pull the
current user. When I use the code below, it still switches the UserName (aka
CreatedBy) in the original record and the newly copied record...

DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, DeliveryVehicle, DistArea, DistQty, DistStartDate, DistEndDate,
ValidStartDate, ValidEndDate, ValidArea, NoteGeneral, Chain, DateAdded,
Cancelled, PromoCouponName, GroupRequesting, OfferType, Requester,
HurdleType, HurdleNumber, ProgrammedOrNot, RewardsOrNot, " & Chr(34) &
fOSUserName() & Chr(34) & " AS CreatedBy, MoreThan10stores FROM
tbl_MainBarcode_Single_new WHERE [BarcodeID] = " & Chr(34) &
Forms!frm_Entry_SingleItem.BarcodeID & Chr(34)

I'm not sure if this would affect anything, but in the Private Sub where
this SQL resides (for the command button), there are also these things
happening:

Private Sub Copy_Click()
DoCmd.RunMacro "mcr_a_BeforeCopy_single" **unlocks the barcode & createdBy
field**
DoCmd.SetWarnings 0 **self explanitory**
DoCmd.RunSQL .... **as noted above**
DoCmd.RunMacro "mcr_AfterCopy_single" **sets focus on barcode field**
DoCmd.RunMacro "mcr_msgBox for Copy" **instucts user to assign
barcode to the new record before proceeding**
End Sub

**Also, the form also has a macro on the "after update" event that relocks
the barcode field and createdBy field** ...not sure if I even need to
unlock and relock the CreatedBy aka UserName field for this to work, but I
figured it wouldn't hurt.

Thank you again for all the help!
--
dl


Douglas J Steele said:
That doesn't make any sense.

Try something along the lines of:

Dim strSQL As String

strSQL = "INSERT INTO tbl_MainBarcode_Single_new " & _
"SELECT BarcodeID, OfferDetail, DeliveryVehicle, " & _
"DistArea, DistQty, DistStartDate, DistEndDate, " & _
"ValidStartDate, ValidEndDate, ValidArea, " & _
"NoteGeneral, Chain, DateAdded, Cancelled, " & _
"PromoCouponName, GroupRequesting, OfferType, " & _
"Requester, HurdleType, HurdleNumber, ProgrammedOrNot, " & _
"RewardsOrNot, " & Chr(34) & fOSUserName() & Chr(34) & _
" AS CreatedBy, MoreThan10stores " & _
"FROM tbl_MainBarcode_Single_new " & _
"WHERE [BarcodeID] = " & Forms!frm_Entry_SingleItem.BarcodeID

Debug.Print strSQL

DoCmd.RunSQL strSQL

Go to the debug window (Ctrl-G) and see what gets written out as the SQL.
Copy that into a query and run it.

If BarcodeID is text, change that last line to

"WHERE [BarcodeID] = " & Chr(34) &
Forms!frm_Entry_SingleItem.BarcodeID & Chr(34)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


dl said:
Well, the form shows the field that stores the UserName, so after hitting the
command button, which runs the SQL, the new (copy) record has the same
UserName as the one I just copied - instead of pulling my UserName and
putting it on the new/copied record. Does that make sense?

So I'm able to see that the UserName doesn't change when a copy is made (the
record I'm copying of course has another person's UserName, so I can see if
it replaces it with mine). To double-check I always look within the table
itself, as well.

thanks for any help you can give!
--
dl


Douglas J. Steele said:
How can you tell? What other difference is there between the two rows that
enable you to tell which record is which?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hi Douglas,
Thank you for the code! I'm now only having one issue, when the "new"
record is created the userName on the "old" record and the "new" record
seem
to swtich. So now the original record shows the new userName and the
"new"
record shows the old userName.

Can someone tell me what I'm doing wrong?

Here's the code:
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, DeliveryVehicle, DistArea, DistQty, DistStartDate,
DistEndDate,
ValidStartDate, ValidEndDate, ValidArea, NoteGeneral, Chain, DateAdded,
Cancelled, PromoCouponName, GroupRequesting, OfferType, Requester,
HurdleType, HurdleNumber, ProgrammedOrNot, RewardsOrNot, " & Chr(34) &
fOSUserName() & Chr(34) & " AS CreatedBy, MoreThan10stores FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] =
Forms!frm_Entry_SingleItem.BarcodeID)"


Thank you!!!
--
dl


:

DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... " & Chr(34) & fOSUserName() & Chr(34) & " AS CreatedBy
FROM
tbl_MainBarcode_Single_new WHERE ([BarcodeID] = " &
Forms!frm_Entry_SingleItem.BarcodeID


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi Jeff,
I've used your suggestions from this posting and they work
beautifully.
However, I've run into an issue; when someone copies a record

(here's my code for the copy)
DoCmd.RunSQL "INSERT INTO tbl_MainBarcode_Single_new SELECT BarcodeID,
OfferDetail, ... CreatedBy FROM tbl_MainBarcode_Single_new WHERE
([BarcodeID]
= Forms!frm_Entry_SingleItem.BarcodeID)"

...it copies the userName field as well, I'd like it to pull the
current
users network ID for the "new" record they've just created (via copy).
Any
guidance as to how I might accomplish this?
--
dl


:

What did you name the module itself?
It cannot be the name of any procedure or function.
Rename the module to something like basUserName.
Compile the code and then retest.

--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:

Jeff,
Thanks for the help. I inserted the code in a new module and named
it
accordingly. To display the name captured, I setup a text box on
the
main
form with the control source as =fOSUserName() when I start the DB
is
get the
following in the box #Name? any suggestions?
 
Back
Top