New User - Time, and date Stamp

K

Kim

I'm building a tracking database. How do I create a date and time stamp for
each time some updates my form. I want to includ the name, time and date
they last updated the form. Is this possible? I've only been using this for
about 2 weeks. Can someone help me please.
 
A

Arvin Meyer [MVP]

Get the Windows username as a function an set the value of the lastuser
field to it.:

http://www.mvps.org/access/api/api0008.htm

write the Now() function to the lastupdated timestamp field. You may use the
BeforeUpdate event to write the values, something like (air code):

Sub Form_BeforeUpdate(Cancel As Integer)
Me.txtLastUser = fOSUserName()
Me.txtLastUpdated = Now()
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
J

Jake F

I used this method but I think I missed a step or placed something in the
wrong are because when I update some date I get a compile error that it
expected a variable or procedure but not a module. The link said to put it
into a module so what part am I doing wrong? I've included my code as well.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[LastUser] = fosUserName()
Me.[LastUpdated] = Now()
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & "Do you wish to save the changes?"
strMsg = strMsg & " Click Yes to Save or No to Discard changes."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub

Thanks for any help.
 
G

George Nicholson

You have a procedure named fosUserName (from the website), and its related
API apiGetUserName, in a general code module?

- General code module = *not* attached to an Access Form, Report or other
object. Created in the VBE by Insert>Module
- Code module can't have same name as the procedure (i.e., don't the module
fosUserName)

--
HTH,
George


Jake F said:
I used this method but I think I missed a step or placed something in the
wrong are because when I update some date I get a compile error that it
expected a variable or procedure but not a module. The link said to put
it
into a module so what part am I doing wrong? I've included my code as
well.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[LastUser] = fosUserName()
Me.[LastUpdated] = Now()
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & "Do you wish to save the changes?"
strMsg = strMsg & " Click Yes to Save or No to Discard changes."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub

Thanks for any help.

Arvin Meyer said:
Get the Windows username as a function an set the value of the lastuser
field to it.:

http://www.mvps.org/access/api/api0008.htm

write the Now() function to the lastupdated timestamp field. You may use
the
BeforeUpdate event to write the values, something like (air code):

Sub Form_BeforeUpdate(Cancel As Integer)
Me.txtLastUser = fOSUserName()
Me.txtLastUpdated = Now()
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
J

Jake F

I copied the procedure into a new module which I named foSUserName like the
it said. I'm not sure what tells if it is a general code module or a code
module though?

George Nicholson said:
You have a procedure named fosUserName (from the website), and its related
API apiGetUserName, in a general code module?

- General code module = *not* attached to an Access Form, Report or other
object. Created in the VBE by Insert>Module
- Code module can't have same name as the procedure (i.e., don't the module
fosUserName)

--
HTH,
George


Jake F said:
I used this method but I think I missed a step or placed something in the
wrong are because when I update some date I get a compile error that it
expected a variable or procedure but not a module. The link said to put
it
into a module so what part am I doing wrong? I've included my code as
well.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.[LastUser] = fosUserName()
Me.[LastUpdated] = Now()
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & "Do you wish to save the changes?"
strMsg = strMsg & " Click Yes to Save or No to Discard changes."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub

Thanks for any help.

Arvin Meyer said:
Get the Windows username as a function an set the value of the lastuser
field to it.:

http://www.mvps.org/access/api/api0008.htm

write the Now() function to the lastupdated timestamp field. You may use
the
BeforeUpdate event to write the values, something like (air code):

Sub Form_BeforeUpdate(Cancel As Integer)
Me.txtLastUser = fOSUserName()
Me.txtLastUpdated = Now()
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I'm building a tracking database. How do I create a date and time stamp
for
each time some updates my form. I want to includ the name, time and
date
they last updated the form. Is this possible? I've only been using
this
for
about 2 weeks. Can someone help me please.
 
D

Dirk Goldgar

Jake F said:
I copied the procedure into a new module which I named foSUserName like the
it said.

The module must *not* be named "fOSUserName", as that is the name of the
function. Call the module "basOSUserName", or "modOSUserName", or something
like that.
 
J

Jake F

Thank you very much. It works perfectly now.

Dirk Goldgar said:
The module must *not* be named "fOSUserName", as that is the name of the
function. Call the module "basOSUserName", or "modOSUserName", or something
like that.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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