this code change textbox from database 2dab using database bonus and database prodloca
2dab is new database with form containing text0 & text2
so edit/update is easy to build in.
also is there example how to communicate with extern form
Code:
Option Compare DatabaseOption Explicit
Private Sub Text0_AfterUpdate()
Debug.Print "bon upd 0";
End Sub
Private Sub Text0_Change()
Debug.Print "bon ch0";
End Sub
Private Sub Text2_AfterUpdate()
Debug.Print "loc upd 2"
End Sub
Private Sub Text2_Change()
Debug.Print "loc chg2"
End Sub
Private Sub Text2_Enter()
Dim db1 As Database
Dim rs1 As Recordset
Set db1 = OpenDatabase("C:\Users\arnol\OneDrive\Documents\bonus.accdb")
Set rs1 = db1.OpenRecordset("select * from [annual bonus]")
rs1.MoveLast
rs1.MoveFirst
If Forms![2dab]!Text0 = "bon" & rs1.Fields(1) Then
Forms![2dab]!Text0 = "bon" & rs1.Fields(0)
End If
Debug.Print "bon"; rs1.RecordCount
Dim db2 As Database
Dim rs2 As Recordset
Set db2 = OpenDatabase("C:\Users\arnol\OneDrive\Documents\prodloca.accdb")
Set rs2 = db2.OpenRecordset("select * from tbllocation")
rs2.MoveLast
rs2.MoveFirst
If Forms![2dab]!Text2 = "loc" & rs2.Fields(1) Then
Forms![2dab]!Text2 = "loc" & rs2.Fields(0)
Else
Forms![2dab]!Text2 = "loc" & rs2.Fields(1)
End If
Debug.Print "loc"; rs2.RecordCount
End Sub