I have 2 table that mirror one another so all the fields are the same.
Table Inv1 and Table Inv2
A form with a sub form showing like a split pulling data from both tables. Main form showing Inv1 and subform pulling data fromInv2.
What I am wanting to do is have a button that runs vb code that will move the record it is currently showing from Inv1 to Inv2 and at the same time move the current record showing in the subform which pulls from Inv2 to be moved to Inv1. (Basically it is swapping the two records location.)
In doing this I need to have some of the fields in Inv1 to stay static for the new record coming over; like Name and location.
I am including the code I setup but it isn't working properly maybe someone could assist me in getting this to work properly.
Thanks in advance.
Table Inv1 and Table Inv2
A form with a sub form showing like a split pulling data from both tables. Main form showing Inv1 and subform pulling data fromInv2.
What I am wanting to do is have a button that runs vb code that will move the record it is currently showing from Inv1 to Inv2 and at the same time move the current record showing in the subform which pulls from Inv2 to be moved to Inv1. (Basically it is swapping the two records location.)
In doing this I need to have some of the fields in Inv1 to stay static for the new record coming over; like Name and location.
I am including the code I setup but it isn't working properly maybe someone could assist me in getting this to work properly.
Code:
Private Sub Relocate_DblClick(Cancel As Integer)
If MsgBox("Send to History and Make Changes." _
& vbCrLf & vbCrLf & "Do you want to Move this record to History and Apply Changes?" _
, vbYesNo, "Changes Made...") = vbYes Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "Inv1 Query"
DoCmd.OpenQuery "Inv2_Query"
DomCmd.OpenQuery "Swap-Inv2_Delete"
DoCmd.Save
DoCmd.SetWarnings True
Else
DoCmd.RefreshRecord
End If
Me![Inv1 subform]![Machine_Name] = Me!Machine_Name
Me![Inv1 subform]![Seat_Num] = Me!Seat_Num
Me![Inv1 subform]![Station_Num] = Me!Station_Num
'Me![Inv1 subform]![Floor] = Me!Floor
Me![Inv1 subform]![Dual_Monitor] = Me!Dual_Monitor
Me![Inv1 subform]![Supervisor] = Me!Supervisor
Me![Inv1 subform]![Monitor_Make] = Me!Monitor_Make
Me![Inv1 subform]![Monitor_Size] = Me!Monitor_Size
Me![Inv1 subform]![Monitor_Make2] = Me!Monitor_Make2
Me![Inv1 subform]![Monitor_Size2] = Me!Monitor_Size2
Me!Service_Tag = Me![Inv1 subform]!Service_Tag
Me!Model_Num = Me![Inv1 subform]!Model_Num
Me!Memory = Me![Inv1 subform]!Memory
Me!Machine_Name = Me![Inv1 subform]!Machine_Name
Me!Seat_Num = Me![Inv1 subform]!Seat_Num
Me!Station_Num = Me![Inv1 subform]!Station_Num
'Me!Floor = Me![Inv1 subform]!Floor
Me!Dual_Monitor = Me![Inv1 subform]!Dual_Monitor
Me!Supervisor = Me![Inv1 subform]!Supervisor
Me!Monitor_Make = Me![Inv1 subform]!Monitor_Make
Me!Monitor_Size = Me![Inv1 subform]!Monitor_Size
Me!Monitor_Make2 = Me![Inv1 subform]!Monitor_Make2
Me!Monitor_Size2 = Me![Inv1 subform]!Monitor_Size2
Me!Comments = Me![Inv1 subform]!Comments
Me!Date_of_Deployed = Me![Inv1 subform]!Date_of_Deployed
DoCmd.Save
Beep
MsgBox "Your request has been processed, Thank you!", vbInformation, "Records Swapped"
DoCmd.Close acForm, "frmSearch_Results"
Thanks in advance.