Home > Archive > MS Access Multiuser > January 2006 > Creating & Editing a Log File









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Creating & Editing a Log File
jhrBanker

2006-01-12, 11:24 am

I have a Table bound to my Main form that opens automatically (autoexec).
The table contains an Auto field, UserID, Date/Time In & Date/Time out fields.
When the user opens the database the Main form opens and a record is created
with the Auto field(Key), UserID and Date/Time In. When the user closes the
Main form to exit the application, I want to find the record and edit it to
include the Date/Time Out. I'm able to create the initial record, but
nothing I've tried will add the Date/Time Out when the user exits. I can't
even determine how to locate the record, since the Key field is an Auto
field. The only other way I can figure to identify the initial record is by
a combination of UserID & Date/Time In. But all the search methods I've
found seem to work with only one field. Does anyone have any sample code
that fits my criteria?
Thanks,
JR
tina

2006-01-13, 3:24 am

if the table is bound to the Main form, the record you create when the form
opens should remain the Current record in the form - unless you close the
form or specifically move to another record. since the user closes the same
form, to exit the db, you should be able to simply add the Date/Time Out to
the current record. what happens when you try to do that?

hth


"jhrBanker" < jhrBanker@discussion
s.microsoft.com> wrote in message
news:3B67FCA2-9CF6-4D2F-8804- E40B989CD345@microso
ft.com...
> I have a Table bound to my Main form that opens automatically (autoexec).
> The table contains an Auto field, UserID, Date/Time In & Date/Time out

fields.
> When the user opens the database the Main form opens and a record is

created
> with the Auto field(Key), UserID and Date/Time In. When the user closes

the
> Main form to exit the application, I want to find the record and edit it

to
> include the Date/Time Out. I'm able to create the initial record, but
> nothing I've tried will add the Date/Time Out when the user exits. I

can't

> even determine how to locate the record, since the Key field is an Auto
> field. The only other way I can figure to identify the initial record is

by
> a combination of UserID & Date/Time In. But all the search methods I've
> found seem to work with only one field. Does anyone have any sample code
> that fits my criteria?
> Thanks,
> JR



George Nicholson

2006-01-13, 1:24 pm


As an update query, using a subquery to select the record to update:

strUserID = "CurrentUserID"

strSQL = "UPDATE UsageLog SET DateTimeOut = Now() "
strSQL = strSQL & "WHERE (((UsageLog.UserID)='" & strUserID & "') "
strSQL = strSQL & "AND ((UsageLog.DateTimeIn)= "
strSQL = strSQL & "(SELECT Max(UsageLog.DateTimeIn) FROM UsageLog WHERE
UserID = '" & strUserID & "')));"

CurrentDB.Execute strSQL, dbFailOnError

The subquery:
"(SELECT Max(UsageLog.DateTimeIn) FROM UsageLog WHERE UserID = '" &
strUserID & "')"
Gets the Current User's most recent LogIn time. That value is then used as
the criteria for the record to be updated. UserID is used as a 2nd criteria,
just in case multiple users have the same login time.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"jhrBanker" < jhrBanker@discussion
s.microsoft.com> wrote in message
news:3B67FCA2-9CF6-4D2F-8804- E40B989CD345@microso
ft.com...
>I have a Table bound to my Main form that opens automatically (autoexec).
> The table contains an Auto field, UserID, Date/Time In & Date/Time out
> fields.
> When the user opens the database the Main form opens and a record is
> created
> with the Auto field(Key), UserID and Date/Time In. When the user closes
> the
> Main form to exit the application, I want to find the record and edit it
> to
> include the Date/Time Out. I'm able to create the initial record, but
> nothing I've tried will add the Date/Time Out when the user exits. I
> can't
> even determine how to locate the record, since the Key field is an Auto
> field. The only other way I can figure to identify the initial record is
> by
> a combination of UserID & Date/Time In. But all the search methods I've
> found seem to work with only one field. Does anyone have any sample code
> that fits my criteria?
> Thanks,
> JR



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com