dcsimg
Results 1 to 4 of 4

Thread: date time in and out

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2012
    Posts
    3

    date time in and out

    Hello, can someone help me with this one
    how can i add a data into database without using .ADDNEW


    DATE IN | DATE OUT (LIKE THIS)
    1 1

    if i use .ADDNEW the data will go down

    DATE IN | DATE OUT
    1
    1

    i just want to log the date time in and out on the same row
    i just finish my login and logout

    any help plz..

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,084

    Re: date time in and out

    Well there are 3 options that I can think of 2 apply only if you actually want to update an existing record the other if you do in fact need to add a new record.

    For an existing record you can use the same methods that would be used with the .addnew except you must be on the record you want to change and do not use the .addnew statement by default it will be in edit mode and when the .update method is called will update the current record int he database.

    The other option for an existing record is to execute a SQL Update statement.

    In the case of adding a new record the other option is to execute a SQL Insert statement.

    Can't tell from your post what you are trying to do.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2012
    Posts
    3

    Re: date time in and out

    uhm..
    in my first login it will log the TIME IN
    and in my second login it will log the TIMEOUT

    on the same row in the database not in the new row


    If .Fields("login1") = "" Then
    .AddNew
    .Fields("login") = txtUser.Text
    .Update
    Else
    If .Fields("login1") = "1" Then
    .MoveFirst
    .Update ("logout"), 5

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,084

    Re: date time in and out

    This won't work
    Code:
    .Update ("logout"), 5
    As I said above you do it the same way but without the .addnew

    Code:
    .Fields("login") = txtUser.Text
    .Update
    Of course you would need to change that field to the one you want to put the data in and the value to the value you want.

    Also be aware that if you are planing to record more than one login then moving to the first record will not work for you as it would only apply to the first login. If you want to keep using the same record then you would only use the addnew the very first time a user logged in.

    Not enough code provided to tell what you are attempting there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width