Results 1 to 7 of 7
  1. #1
    Sweetu is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2016
    Posts
    19

    Passing two same data field into two different tables

    I've two tables
    Table 1 named as "ComingIn"
    Fields: AutoID,CustomerNumber,Check_In_time,Check_In_Date, Location

    Table 2 named as "GoingOut"
    Fields: CustomerNumber,Check_Out_Date,Check_Out_Time,Locat ion



    To make changes in two tables I've two forms respectively as table names,

    How can we use vba code to,if we add new CustomerNumber in Form "ComingIn" than this CustomerNumber should be automatically added to another table's (GoingOut) CustomerNumber field??

    And when I make changes to location should be change in both tables to their CustomerNumber...

    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you dont need 2 fields for date and time. A single date/time field holds both. This way you can calculate elapsed time.
    having 2 fields makes it harder.

    table 1 has autoID, so when that record is created, grab the AutoID and run an append query to post this to Table2.
    table2 will need a FK field (called MatchID, or Table1ID)

    user enters new record
    autoID, CustNum, CheckIn, Location

    user clicks Save button, run the append query to write to table2
    Table1id, CustNum, CheckOut, Location (where table1.autoID =form1. txtbox)

  3. #3
    Sweetu is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2016
    Posts
    19
    No....
    Before I created all fields on same table1 but when I created two separate forms one for check-in another for check-out...
    While changing checkout Access through an error write conflict....

    That's why I created two separate tables...
    How can I write vba on save button for only CustomerNumber to append in another table..?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you DO need 2 separate tables,
    you DONT need 2 time fields / table.
    you only need 1 DateTime field in each. you have 2 fields, 1 for date, 1 for time.

    in the click event for the button, run a macro
    this macro runs the append query.

  5. #5
    Sweetu is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2016
    Posts
    19
    I understand date/time

    Would you please explain the vba syntax/variables? To do append data?

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    No syntax, use query builder ,make a query,
    add the items on the form, (use the builder)
    then run the query.

    something like,
    insert into table2 (custID,date,location) values(forms!myForm!txtCustID,forms!myForm!txtDate ,.....)

  7. #7
    Sweetu is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2016
    Posts
    19
    I know this dear....
    But I want this to add only for new entry...while append query will append all...

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

Similar Threads

  1. Replies: 2
    Last Post: 08-07-2014, 07:31 AM
  2. Replies: 1
    Last Post: 05-11-2014, 10:04 PM
  3. Replies: 1
    Last Post: 05-21-2013, 12:02 PM
  4. Replies: 3
    Last Post: 08-18-2012, 03:25 AM
  5. Replies: 3
    Last Post: 02-08-2010, 09:00 AM

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