Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    the more you try to explain the more confusion is created .
    i understand : - you are familar with using 2 databases same time
    - you are using a function in after update
    - you like to use that function in vba
    - why you need a trigger if you activate the function?


    if you need the function in the other database i would use recordset for the 2nd database so i can use the function from the 1st database

  2. #17
    Anna987 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    22
    Quote Originally Posted by CJ_London View Post
    for this to work, you (not another user) would have the have database2 open from within database1(and to be clear - you mean a front end, not a database which is the back end) and the relevant form open as well to be able to reference the control.

    All depends what your function is supposed to do but perhaps a data macro is the way to go....
    I'll try the data macro, thanks CJ.

  3. #18
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    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
    Attached Files Attached Files

  4. #19
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    If it's in another database, then a data macro would be the most appropriate method, as it works when the table data is updated, no matter when or how the update is made.

    I'm not sure of the relationship between the two tables or databases, but it might not be possible across two systems,
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #20
    Anna987 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    22
    Quote Originally Posted by Minty View Post
    If it's in another database, then a data macro would be the most appropriate method, as it works when the table data is updated, no matter when or how the update is made.

    I'm not sure of the relationship between the two tables or databases, but it might not be possible across two systems,
    Thanks Minty

  6. #21
    Anna987 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    22
    Hello Ano,

    I have tested the TestfromAccess and the TargetDatabase. This can work for me, i have to try it further but until now , i like it.
    Many Tahnks.

    Regards.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Changing value of bound field on event
    By Ganymede in forum Programming
    Replies: 5
    Last Post: 02-17-2016, 12:27 PM
  2. Trigger event with button click
    By AMAS in forum Forms
    Replies: 8
    Last Post: 06-07-2012, 09:42 AM
  3. event to trigger after new record
    By richlyn in forum Access
    Replies: 1
    Last Post: 03-02-2012, 10:26 AM
  4. Changing value of a field after an event.
    By mikethebass in forum Access
    Replies: 1
    Last Post: 06-16-2010, 04:42 PM
  5. Trigger subform event
    By tuna in forum Forms
    Replies: 0
    Last Post: 05-09-2010, 06:29 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