Results 1 to 7 of 7
  1. #1
    Anna987 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    22

    Read value from field on other form

    Hello,

    I'm trying to read the value from a field in a form in to a field from another form. (read value from controlfield in form1 in to controlfield from form2)
    In the fieldbox property controlsource from form2 i type this =Forms!form1!field1


    The form1 is open and this field is on the mainform.
    Form1 is in the same database.
    I get the error "Form1 not found"
    Can someone help me out...

    Thanks in advance.

    Bieke

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,552
    Code:
    =[Forms]![frmDailyEntry]![txtWeekDay]
    works for me. the [] was put in by Access.
    So I would say you have the formname wrong as Access does not lie.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Anna987 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    22
    I'm sorry, i realise that the form1 is from another database, Is there a possibilty then ....?

    Bieke

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,552
    You can reference another DB, but I am not sure how you would then reference the forms.

    See if this helps Open Form in another DB

    I believe if you open that form in the other DB, then it will become part of the Forms collection, so the same syntax would work.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Anna987 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Feb 2015
    Posts
    22
    I've find another solution, with a shared table from one database to another.
    Thanks for helping.

    Regards, Bieke

  6. #6
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    i would opt for dim db1=otherdbpath with sql recordset

  7. #7
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    to open a 2nd database use something like this:
    as u see the msgbox can also display ur field from subform
    just change ur strdb and add the code where u like to use it
    this is loaded once at startup form calling displayform
    Code:
     Sub DisplayForm()
    Dim strDB As String
    Dim db1 As Database
    Dim strSQL As String
    Dim rs As Recordset
    strDB = "C:\cctv\rownumbering.accdb"  '2nd database not in use
    Set db1 = OpenDatabase(strDB)
    strSQL = "Select * from transactions where [customerid] = 5"
    Set rs = db1.OpenRecordset(strSQL)
    rs.MoveFirst
    MsgBox rs.Fields("TransactionAmount") & "/" & rs.Fields("customerid")  & Forms!form1![salary changes]!Name
    End Sub
    
    
    Private Sub Form_Load()
    DisplayForm
    End Sub

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

Similar Threads

  1. Form Caption to Read Field Entry
    By sgross in forum Forms
    Replies: 3
    Last Post: 01-16-2017, 10:58 AM
  2. Read Design & Read Data Issue
    By f15e in forum Access
    Replies: 7
    Last Post: 10-18-2016, 12:44 AM
  3. Read only field on Split form
    By casinc815 in forum Forms
    Replies: 1
    Last Post: 04-26-2014, 02:51 PM
  4. Read and update a field in another table.
    By Artist.Anon in forum Programming
    Replies: 2
    Last Post: 08-28-2012, 06:56 AM
  5. Replies: 2
    Last Post: 10-19-2006, 04:37 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