Results 1 to 4 of 4
  1. #1
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200

    Reference recordset of different form

    Hello,



    I am using the following code to refer to a control on a different form.

    Code:
    Forms![FormName]![FormField]
    However, I found that unless that field exists as a control on that form this won't work.

    How do I reference a field on a different form if that field doesn't necessarily exists as a control on the form but only as a field in the recordset of the form.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if you're using it as a reference in VBA script you can test to see if the other form is open, if it is, use the reference as you have it, if it's not use the reference from the form you currently have open.

    here's an example of finding out if a form is open:

    http://custom-designed-databases.com...xist-function/

    yours would likely be easier because you just want to check one form.

  3. #3
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200
    I know the form is open. And I know the field I am trying to reference exists in its recordset. I'm just trying to figure out the syntax that allows me to reference it.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    oh I misread your original post. You're saying a FIELD exists in the recordset of the form but it may not exist in the actual display of your form. If that's the case you would have to recreate the data source in your code exactly as it is in the form that contains your data or put the field into your form and make it's visible property false, then you can reference it the way you have it but your users will not see it when they open the form itself.

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

Similar Threads

  1. Replies: 3
    Last Post: 05-08-2013, 01:29 PM
  2. Sub-form reference incorrect?
    By GraeagleBill in forum Programming
    Replies: 3
    Last Post: 11-30-2012, 06:45 PM
  3. Replies: 2
    Last Post: 03-08-2012, 12:59 PM
  4. Wrong reference with .fields in DAO recordset
    By ddd in forum Programming
    Replies: 1
    Last Post: 12-08-2009, 05:34 PM
  5. Form Name Reference in VBA
    By Simon Sweet in forum Programming
    Replies: 0
    Last Post: 05-22-2008, 01:55 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