Results 1 to 7 of 7
  1. #1
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212

    retrieve data from unbound control on form

    Is it possible to retrieve data from unbound control on form.



    I want to put it in a document as a mergefield.

    So could I reference the control on a form from a query?

    The field in question is the summation of several other fields. I originally had all this in a query, but it seemed to make the query unstable. So I created all the feeder information in a form. But how to get that piece of data from the form into a document?

    Thanks for any insight.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    My experience is that you cannot reference an unbound control within a Query Object. If the control is not bound to a table or a query, Access will not know what to do with it.

    One option might be to use a custom function to get the info you need from the unbound control. Here is some info on using a custom function within a query. It is about one third down the page (Using Custom Functions)
    http://www.fmsinc.com/tpapers/queries/

  3. #3
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044
    Hi,

    you can reference the unbound control in a query using: [Forms]![Name Form]![Name control]

    kind regards
    NG

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by NoellaG View Post
    Hi,

    you can reference the unbound control in a query using: [Forms]![Name Form]![Name control]

    kind regards
    NG
    I stand corrected. I just created a test DB and was able to do it.
    On a side note ...
    Previously, I was having trouble getting it to work in a DB I am developing. I must be dealing with a corrupt DB file because I was unsuccessful in using unbound controls. In this same DB, I just tried using bound controls and I keep having problems there too. After an indeterminate amount of time, the Query will automatically change the form name defined in the parameters to the first form in the application's forms collection. Bummer for me.

  5. #5
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212
    Thanks for the info. I finally managed to do it. I passed the information from the unbound control to a new bound control on the form. thus it was available to me for the document.

    If you have deduced that your database is corrupt, what will you do with it?

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by Abacus1234 View Post
    ...
    If you have deduced that your database is corrupt, what will you do with it?
    I just now rebuilt it and it seems to be functioning better.

    When I build an app I expect it to become unhappy over time. So I am constantly compiling the VBA code and doing compact and repairs. When I make changes to the design, I save often and pay attention to how many objects I am simultaneously editing. Also, I pay attention to how many controls, over time, I have created for a particular form. For instance, when I add a new control to a form, I look at the default name and see what number is included within the name. If the number is over 100, I will consider rebuilding the form. I will create a new form and copy the controls over to the new form using copy and paste. Then I, very carefully, copy over the VBA to the form's module. Before I deploy an app, I will go through a process of importing objects into a new file and then use that as my Master file.

    In the case of the queries not working, this is a new one for me and it was not a specific query that was creating the issue. I could build a new query and the new query would behave badly. Because of the symptoms, I assumed the issue was in the system tables. Since the Table Objects I created were not displaying symptoms, I created a new blank DB file and began importing the tables via the Wizard. I was sure to use the advanced options and not include "Relationships". I used the advanced options within the Wizard to avoid importing any System Tables or System Table data. Then I moved onto the queries.

    Instead of importing the queries, I copied and pasted the SQL from the old ones into new Queries within the new DB. I also copied and pasted the names as I saved the new query objects. I removed any references to Forms within the queries' criteria. Then I used the Wizard to import the rest of the objects.

  7. #7
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212
    Thanks very much for all the ideas on re-building a database. Really very helpful.

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

Similar Threads

  1. Replies: 3
    Last Post: 06-17-2015, 01:16 PM
  2. Replies: 1
    Last Post: 07-26-2013, 12:10 PM
  3. Form unbound field control problem?
    By justphilip2003 in forum Forms
    Replies: 22
    Last Post: 04-18-2013, 03:39 PM
  4. Submit and retrieve data in a form
    By Bertrand82 in forum Import/Export Data
    Replies: 1
    Last Post: 10-05-2012, 11:44 AM
  5. Replies: 1
    Last Post: 03-09-2012, 07:43 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