Results 1 to 6 of 6
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    combo not working with subform

    All; using access 2010. I had a blank form. I want use the form to put a combo box for custid. I use a query based on a table with custid and maxdescription for the record source. I created the combo box. Then I inserted a subform with custid description and other data to appear as datasheet view. During the insertion of the subform; it suggested that I use the maxdescription as link master and address as child link which I thought was odd. I changed it to custid for both master and child links. When I view the form; I used the combo box to select one of the custid’s that I know is in the subform. It didn’t select anything. I’ve done this hundreds of times and I can’t find what’s wrong! I planned to put code to filter; but this basic wizard should work without code! My initial thought was the datatype for both master and child links are text; but I have used this datatype in links before. Please help me figure this out.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    You dont need the sub form. Have the form.recordsource point to the table too,( w all the fields)....when you pick the ID in combo box, just filter the form.

    Code:
    me.filter = "[ID]=" & me.combobox
    me.filteron = true

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    There may be a way to use the Wizard exclusively to cause a subform to be dependent on a combo but, I am not imaging a way right now. I use VBA to change the subform's .Filter or .Recordsource property. This approach requires there not be a Main/Child link between subform and main form

    Perhaps changing the Recordsource of the subform (the form object inside the subform container) to something like this. And I think maybe a Requery for the subform in the combo afterupdate (can't remember if needed).

    SELECT * FROM QueryName WHERE [custid] = " & Forms!MainFormName.ComboName

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    To be honest I am not following your description of the problem

    You say your main form has the CUSTID on it and it is based on a query with 'maxdescription' if you are using an aggregate query (non-updatable) as your MAIN FORM data source I don't know if that would cause you any issues in the subform (I've never tested it but it's something to check). Secondly you say that when you added the subform it suggested maxdescription as the link, so if you are using an aggregate query in the SUBFORM you will definitely not be able to update or add any records in the subform. If this is strictly a lookup form and you are selecting a customer on the mainform and wanting to see what's related to it in the subform your main form you would have to issue a requery command once the customer is selected and the customerID combo box on the main form would have to be unbound and the criteria for the query driving the main form would have to be something like

    [forms]![mainformname]![customeridcomboboxname]

    then in the ON CHANGE (or similar event)
    you'd have to issue a me.requery command for your form to force the data to refresh.

    It might be easier to post a sample of your database as we have different impressions of what your problem actually is.

  5. #5
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Ok. I found the problem. Apparently; you have to have the same named field in both recordsource of the form and subform. My recordsource field was cus_id oppose to the subform cust_id. I don’t remember that being the case as long as the datatypes matched and it is the same data. I further thought as long as the subform and the combo box matched datatype and data it would work. Thanks again for all your suggestions.

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    you don't have to have the same field in both form and subform, access suggests fields that are the same name, but if you type in your own and you mistype one it's not going to work, better to use the interface so you make sure you're selecting fields to link that actually exist

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

Similar Threads

  1. Replies: 4
    Last Post: 10-08-2012, 05:33 PM
  2. subform not working
    By ermcc in forum Access
    Replies: 1
    Last Post: 05-31-2012, 03:54 PM
  3. Subform not working
    By aceoftrades in forum Forms
    Replies: 9
    Last Post: 03-09-2012, 03:06 PM
  4. Replies: 33
    Last Post: 01-13-2012, 07:44 AM
  5. Replies: 5
    Last Post: 01-02-2011, 10:09 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