Results 1 to 9 of 9
  1. #1
    vCallNSPF is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    49

    Update in seperate table


    I have two tables

    one is ClientDetails
    the other is ClientContactDetails

    in the form for ClientContactDetails i have a last edited field called UpdateDate. i have a button on the form which has a save form function. it also has an on click function "me.UpdateDate = Date()" which updates the UpdateDate field to todays date.

    The problem is, when i click the save button i also want it to update an UpdateDate field in the ClientDetails table, how to i change the on click function to update in the other table aswell?

  2. #2
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows XP Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Why would you change the Last Update in a Table where nothing has been updated?

  3. #3
    vCallNSPF is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    49
    Quote Originally Posted by Rainlover View Post
    Why would you change the Last Update in a Table where nothing has been updated?
    I have a report at the end which gives the illusion that the two tables are the same.

    do you know how to do it

    technically i dont need it to update the UpdateDate field in the ClientContactDetails table, since the report only shows the UpdateDate field from the ClientDetails table

  4. #4
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows XP Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    The ClientContactDetails Table may have several records. (At a guess)

    Would you update all these.

    Could be a bit misleading.

    But you could run an Update Query to update all those records. But I don't like it.

  5. #5
    vCallNSPF is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    49
    Quote Originally Posted by Rainlover View Post
    The ClientContactDetails Table may have several records. (At a guess)

    Would you update all these.

    Could be a bit misleading.

    But you could run an Update Query to update all those records. But I don't like it.
    Yeah it does have several records.

    And I want the date updated for any changes in any of the records.

    But all that is beside the point, i basically just need the code because its too hard to explain WHY. wouldnt it be a variation of "me.UpdateDate = Date()". I just need the right syntax to include a tablename aswell.

  6. #6
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows XP Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    No it is not a Variation of me.update.

    You are addressing a Different Table and various records within that Table.

    You need an UPDATE Query that runs on I would think the Before Update Event of the Record.

    I must say that I do not agree with what you are doing as you can always get the Date from the Parent table.

  7. #7
    vCallNSPF is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    49
    Quote Originally Posted by Rainlover View Post
    No it is not a Variation of me.update.

    You are addressing a Different Table and various records within that Table.

    You need an UPDATE Query that runs on I would think the Before Update Event of the Record.

    I must say that I do not agree with what you are doing as you can always get the Date from the Parent table.
    the ClientDetails table only has one record because its only 1 client, there will never be more than 1 client.

    i just need a button on the form for the ClientContactDetails that will change the date in the single UpdateDate field of the ClientDetails table

  8. #8
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows XP Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    If you post a cut down version of what you have, Just those Two tables and the Form, all with dummy data, then I will write something for you.

    Compact and Repair first and Zip it.

  9. #9
    maximus's Avatar
    maximus is offline Expert
    Windows XP Access 2003
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I agree that an update query is required and it can be done by using vb code. Use this

    Dim SQL As String

    SQL = "UPDATE Employees " & _
    "SET Employees.Title = 'Regional Sales Manager' " & _
    "WHERE Employees.Title = 'Sales Manager'"

    CurrentDb.Execute SQL, dbFailOnError

    I am explaining the code
    SQL = "UPDATE Name of the table u want to update " & _
    "SET Name of the table u want to update .Field you want to update = 'Value you want' " & _
    "WHERE Name of the table u want to update.Feild to which u want to attach the criteria = 'Criteria'"

    remember this wil update all the related record and i completely agree with rain lover on this point.

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

Similar Threads

  1. Replies: 0
    Last Post: 10-18-2009, 10:44 AM
  2. Update table
    By metro17 in forum Forms
    Replies: 0
    Last Post: 09-23-2009, 04:42 PM
  3. Making the launched form seperate from Access
    By MonsterMaxx in forum Access
    Replies: 1
    Last Post: 09-06-2009, 12:11 PM
  4. Replies: 4
    Last Post: 09-03-2009, 02:01 PM
  5. split a column into two seperate columns
    By nybanshee in forum Access
    Replies: 2
    Last Post: 08-14-2008, 04:52 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