Results 1 to 5 of 5
  1. #1
    bentod is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    13

    Go to record based on listbox

    I have a listbox of people from a query called "NamePedigreeQRY". The query also has the primary key (F_ID) from my main form/table. The listbox only shows the name of the people, but it does not show the F_ID.

    I want to use a macro to select a person from the list and go to that record in my main form (FamilyFRM). I can use VBA but I'd prefer to use macros.

    I tried to copy an example of a macro of an "After Update" event:


    Action: SearchForRecord
    Arguments: , , First, ="[F_ID] = " & Str(Nz([Screen].[ActiveControl],0))

    It gives me a "Type mismatch" error. I'm guessing it is looking for the FieldAs field from my query = "Washington, George & Martha" instead of the corresponding F_ID = 4. Of course, there is no record in my tables containing "Washington, George & Martha".
    -----------------------------------------------------------------------

    FamilyTBL - Table holds family specific information.
    FamilyFRM - Main form
    IndividualTBL- Table holds family member specific information.
    IndividualFRM - Subform
    Role1QRY - Query to get the father's name.
    Role2QRY - Query to get the mother's name.
    NamePedigreeQRY - Query to concatenate the last name with father and mother.
    FieldAs - Field in the "NamePedigreeQRY" which holds the concatenated name.
    F_ID - Primary key of the family from "FamilyTBL". This is also a column in "NamePedigreeQRY".

    Thank you.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    what is the BOUND column of your combo box? make the BOUND column your F_ID and, from the sound of it, you should be alright.

    if the BOUND column is the text value that's your problem

  3. #3
    bentod is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    13
    It may be obvious, but I am a newb so please forgive my ignorance.

    Control Source: <blank>
    Row Source:
    SELECT NamePedigreeQRY.FiledAs, NamePedigreeQRY.F_ID
    FROM NamePedigreeQRY;
    Bound Column: 1

    I changed the Bound Column to 2 (F_ID) and it will update the record, however, on some names it gives me the following warning:
    "2101 The setting you entered isn't valid for this property."
    All values in the F_ID column have integers greater than 0.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You'd have to show your code and where in that code that error is occurring. You are likely performing some sort of operation like trying to perform an operation on a null string or something. It's impossible to tell without the code and possibly a sample of your database to work with. The error you are encountering likely has nothing to do with the value of F_ID in your list box.

  5. #5
    bentod is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    13
    That makes sense, which means this issue is closed yet another rears its ugly head.

    Thank you for your help.

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

Similar Threads

  1. Replies: 1
    Last Post: 09-10-2012, 11:21 PM
  2. Replies: 1
    Last Post: 07-26-2012, 11:45 AM
  3. Replies: 22
    Last Post: 06-12-2012, 10:02 PM
  4. Replies: 3
    Last Post: 11-29-2011, 12:54 AM
  5. Unable to populate textbox based on listbox
    By marcustofeles in forum Forms
    Replies: 21
    Last Post: 10-24-2011, 07:18 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