Results 1 to 7 of 7
  1. #1
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    run code from text box

    Hi

    I have a form which is created via a query and criteria so that one record is shown.

    In that record is a field called Mlink which relates to several other family records and grave inscriptions.

    When this form is displayed I want to show all other inscriptions

    i.e. Mink 1234 might relate to a husbands memorial and his wife at another grave

    So I added an unbound text field and in the control section of the properties used this code


    Code:
    SELECT tblMemorial.Inscription
    FROM tblMemorial
    WHERE ((([tblMemorial]![Mlink])=[Forms]![frmDetail]![Mlink]));
    The idea being that from table memorial the inscription field is selected subject to the criteria that the Mlink field is equal to the current displayed record Mlink.

    However this does not work so my logic is flawed.

    Can you not use a query as a control source for an unbound text box?


    Any help as usual much appreciated

    thanks



    Ian

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    querys are bound to the form.
    text boxes are bound to fields (in that form query only)

    you may want to use a parent-child table. 1 person, could have many inscriptions or relations to other graves.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Answer is No.

    This is what domain aggregate functions are for.

    Maybe you need a DLookup().
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    thanks

    off to research Dlookup() and parent child relationships

    Ian

  5. #5
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    many thanks

    it seems dlookup was exactly what I wanted.

    Added

    Code:
    =DLookUp("Inscription","tblMemorial","Mlink='" & [MlinkDetail] & "'")
    And the form appeared to behave perfectly and certainly showed exactly what I wanted.

    Ran some more searches and realised that there seems to be a flaw in that when the Dlookup runs it appears to stop once is finds the first match match.
    ie. I have 5 people in a grave with 5 different inscriptions

    John Smith
    Sam Smith
    Ann Smith
    Ian Smith
    Fred Smith

    all linked by this Mlink field.

    When the code runs it seems to stop once it reached John Smith whereas I want it to continue to the end of the table and then display all five results.

    Is there an instruction to do this

    many thanks

    Ian

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    DLookup won't do that. It is behaving as it's supposed to.

    If you want to see all related records, use a subform or a listbox.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    thanks for the quick response, shame I like Dlookup;-)

    time to research sub forms and list boxes

    Ian

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

Similar Threads

  1. Replies: 1
    Last Post: 02-26-2015, 07:45 PM
  2. VBA code to make text box italic
    By tariq1 in forum Programming
    Replies: 5
    Last Post: 07-21-2012, 07:30 AM
  3. Converting a Code to Text
    By rmcafee in forum Programming
    Replies: 7
    Last Post: 09-13-2011, 08:52 PM
  4. code for blank text ???
    By alex_raju in forum Access
    Replies: 1
    Last Post: 08-02-2011, 07:50 PM
  5. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 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