Results 1 to 7 of 7
  1. #1
    Behedwin is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    61

    Question How to add data to record, todays date to selected record?

    Hi



    I have a project going.
    I want to add todays date to selected record when a user press a button.

    I have a listbox called : ListPicker
    I have a button called: hideuser_button
    I have a table called: Profile_Table
    In this table i have a DATE column called: ProfileArchive

    When the user press the button i want to add todays date to the column ProfileArchive on the selected record in the listbox.

    The button i located in the form called: SelectProfile_Form

    I have so far this code

    Code:
    Private Sub DeleteProfile_Button_Click()
    
    Dim strSQL As String
    strSQL = "UPDATE Profile_Table SET [ProfileArchive]= Date() WHERE Profile_ID = " & Forms!SelectProfile_Form!ListPicker
    CurrentDb.Execute strSQL
    
    End Sub
    or this code

    Code:
    CurrentDb.Execute "UPDATE Profile_Table SET [ProfileArchive]=Date() WHERE Log_ID=" & Form_SelectProfile_Form.ListPicker
    Form_SelectProfile_Form.ListPicker.Requery

    But none of them work.
    I get this error message
    http://prntscr.com/haxdb7


    I have this post going on another forum
    https://www.mrexcel.com/forum/micros...ml#post4951398
    But i have so far not found a solution from all the great help there so far. I hope someone here can figure out why my codes wont work or have another solution.
    I hope noone consider this crossposting, if so please delete my post here.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Don't see anything wrong with code. No idea why it is demanding 2 parameters. If you want to provide db for analysis, follow instructions at bottom of my post.

    It is cross-posting but that is okay because you informed us.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Behedwin is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    61
    Quote Originally Posted by June7 View Post
    Don't see anything wrong with code. No idea why it is demanding 2 parameters. If you want to provide db for analysis, follow instructions at bottom of my post.

    It is cross-posting but that is okay because you informed us.
    Yes please have a look at my file
    for some reason the upload on the site did not work for me
    i have uploaded a zip file here:
    https://ufile.io/icm2g

    and the unzipped file here:
    https://ufile.io/uczn7

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Not finding that code in the db. There is DELETE action but no UPDATE. There is no ProfileArchive field.

    Since form is bound to the table, really no need for the UPDATE. Once focus is on desired record just set value into field: Me!ProfileArchive = Date()

    Advise no spaces or punctuation/special characters (underscore only exception) in naming convention.

    Why did forum upload fail? Zip file is certainly small enough.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Behedwin is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    61
    What?
    The ProfileArchived field is in the profile_table

    The delete command button is in the selectprofile_table
    http://prntscr.com/hay03k
    http://prntscr.com/hay0ha
    http://prntscr.com/hay0nt

    I have trying so many variations so im sorry if something is a bit weird.

    Hope you see what i mean in the file now!

    Let me know.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I looked. Not there. There is no ProfileArchive field.

    Presume you mean Profile_Form - nope, that code is not there. Yes, there is a delete button - with DELETE action, not UPDATE.

    Apparently provided wrong version of db.

    Regardless, my advice still applies.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Behedwin is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    61
    i found the problem.

    it was so simple as a misspelling.
    the column name is ProfileArchived
    but the code had ProfileArchive
    without "d" at the end.

    so all this just for this little thing.
    i must have read the code over and over and over and never noticing this.

    thanks for all your help.
    and im sorry for not noticing this before.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 03-01-2017, 10:00 AM
  2. Replies: 3
    Last Post: 02-06-2015, 01:18 PM
  3. Replies: 3
    Last Post: 06-13-2014, 09:16 PM
  4. Replies: 9
    Last Post: 10-12-2011, 02:34 PM
  5. Replies: 1
    Last Post: 10-13-2010, 12:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums