Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376

    Can't figure out to to get what I want

    Hello all,



    I am trying to get a new form to display what I want in a subform, based on some information in the main form but I can't seem to get it figured out how to do it. The subform data is based on a query and what I want to do is to have the query use the DhrID and the DHR_PN:MfgPartNumber info from the main form, then run the query. How do I populate the DhrID and the DHR_PN:MfgPartNumber progmatically if you will in the Criteria fields of the query?

    To illustrate what I am trying to do open the DHR Entry form and you should see the subform has 2 sets of data in it because I can't show only the one I want (either one). I want the DHR_PN:MfgPartNumber not to show up, but be pulled from the DHR Entry form, field name CmbPartNumSelect.

    I hope that makes sense, if not, I'll try to clarify, the file is attached.

    Essentially, I and trying to create a list of all parts that are used in the end item, PartID 2 - 8, Part ID 1 is the end item.

    Cheyenne.zip

    Thanks

    Dave

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,165
    You shouldn't need to do this pragmatically. Using the query designer, in your fields criteria boxes you can right click then select build. From there you can use the bottom left listbox to select your form, then use the middle or right listbox to select your field or control you want to reference.

    Here is an example youtube video: https://www.youtube.com/watch?v=bSV1JXFsFaA

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    not at all clear what you are asking,

    I don't see this >> DHR_PN:MfgPartNumber info from the main form

    either in the form or in the underlying recordsource

    then run the query
    why do you need to run a query? just set the linkmaster/child properties for the subform, you can set more than one separated with a semi colon

    DhrID;DHR_PN

    suggest you provide some example data and what you want

    Your relationships look weird so might also be a good idea to explain what the business does and what this app is supposed to do - and explain some of the industry specific terminology - whatr is a DHR for example

  4. #4
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    kd2017,

    I think I know what you mean, I'll try that, I hadn't thought of that.

    Ajax,

    I know DHR_PN:MfgPartNumber doesn't show up n the form but if you look at the query in the designer, it's there, I'm not sure why it doesn't show up correctly on the form.

    I am not sure what you mean by "just set the linkmaster/child properties for the subform, you can set more than one separated with a semi colon".

    A DHR is a "Device History Record", it's used to record the critical steps and materials in the assembly of a product. This database is a means to capture those steps and materials for many products, obviously this is a sample file in the works.

    Thanks

    Dave

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    like this

    Click image for larger version. 

Name:	Capture.JPG 
Views:	40 
Size:	23.5 KB 
ID:	35982

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    I think Ajax is describing a compound key. Is that how your tables are related - with compound keys?
    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
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    June7,

    No, the tables don't have compound keys, I know about them but at this point, I don't use them. I haven't had a chance yet to try kd2017's suggestion yet, but I believe I know what he is talking about and will try that tomorrow AM. I hadn't thought about that but I think I know what he is describing.

    Thanks

    Dave

  8. #8
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Hmmmmmm
    Looks to me like Ajax is setting the linking Master/child fields for a Main form/sub form design.

    But I can't tell what fields would be linked......

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    no, not a compound key. I don't understand the relationships, but was providing an answer to

    query use the DhrID and the DHR_PN:MfgPartNumber info from the main form, then run the query. How do I populate the DhrID and the DHR_PN:MfgPartNumber progmatically if you will in the Criteria fields of the query?
    looks like two fields are used.

    result returned two recordsets, test1 and test2

  10. #10
    Join Date
    Apr 2017
    Posts
    1,775
    Based on Ajax's post (#5):
    When both main form and child form source tables contain fields dhrID and dhrnumber, subform properties will be LinkMasterFields = "dhrID; dhrnumber" and LinkChildFields = "dhrID;dhrnumber";
    When main form source table contains fields dhrID and dhrnumber, but linked fields in child form source table have different names, like ChildField1 and ChildField2, subform properties will be LinkMasterFields = "dhrID; dhrnumber" and LinkChildFields = "ChildField1;ChildField2";
    When child form must be linked to unbound control in master form, e.g. there in no field dhrnumber in master form source table, but instead you have a unbound combo box cbbDhrNumber, which get's value dhrnumber from some lookup table, subform properties will be LinkMasterFields = "dhrID; cbbDhrNumber" and LinkChildFields = "dhrID;dhrnumber".

    Linking fields MUST be present in child form's source table!

    As result,
    1. subform displays only records where liked fields match with according values in parent form;
    2. whenever a new record is added into subform, controls with linked fields as source will automatically have same values as according current values in parent form. From this follows, user must not edit linked fields in subform - the best will be to hide them at all;
    3. when you add a new record into subform but want to undo this, simply press Esc twice before the record is saved. Adding the row is terminated.

  11. #11
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    I think the OP is fixated on a vba/criteria solution without using the link filtering. Often considered good practice to minimise network traffic, but not done in this way.

  12. #12
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,165
    @Dave14867, It doesn't look like my comment in post #2 is relevant. You are in much more capable hands with the rest of these guys so I'll be sitting the rest of this out. Before I go a few comments [MfgPartNumber] As DHR_PN simply is not available on your main form, you wont be able to filter with this field as is. I believe Ajax mentioned this in post #3. I've taken some screenshots of the db that may help others figure out what is going on.

    DB relationship window:

    Click image for larger version. 

Name:	r1.jpg 
Views:	30 
Size:	104.7 KB 
ID:	35990

    The subform's query in question:

    Click image for larger version. 

Name:	q1.png 
Views:	30 
Size:	43.7 KB 
ID:	35991

    The form and subform in question:

    Click image for larger version. 

Name:	f1.png 
Views:	28 
Size:	61.0 KB 
ID:	35992

  13. #13
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,165
    *MAYBE* you need to change the main form to be based on a query that includes the PARENT's mfrPartNumber, then use that to filter the subform like so:

    Mainform's query like this: (edit: don't need to do this. see below)

    Click image for larger version. 

Name:	q2.png 
Views:	30 
Size:	19.9 KB 
ID:	35993

    And then subform links like so:

    Click image for larger version. 

Name:	f2.png 
Views:	30 
Size:	55.7 KB 
ID:	35994

    Okay, now I'm out for real this time to let the real pros take over. Good luck!

    *EDIT* (I can't help myself)
    Assuming MfgPartNumber is unique, change the subform's query to also include the PartID of the Parent part. Link that PartID to the mainform's PartID field. Then you shouldn't need to use the query in the main form. This is preferable to above as MfgPartNumber is a text field, filtering instead by the ID field is the way to go.

    Click image for larger version. 

Name:	q3.png 
Views:	25 
Size:	27.5 KB 
ID:	35996

    Click image for larger version. 

Name:	f3.png 
Views:	25 
Size:	17.9 KB 
ID:	35997

    **EDIT** do you even need to filter by mfrpartno/partid? Shouldn't the DHRID alone suffice?

  14. #14
    Dave14867's Avatar
    Dave14867 is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Nov 2016
    Location
    Upstate NY
    Posts
    376
    I have part of what I want working, I'll post another zip file later tonight. What I am trying to do is simply create a subform on the "DHR Entry" form that loads all of the parts for the Parent PN (PartID) And then have a field that I can input how many of each part was actually used, then using a command button, have that information written to the transactions table for each part (I am assuming an append query). right now I am hung up on getting a field that I can enter the actual quantity used per part that I can enter the quantity in. I tried creating an unbound field but when I input a qty for 1 part, it populates the same number for all of the parts.

    Thanks

    Dave

  15. #15
    Join Date
    Apr 2017
    Posts
    1,775
    Quote Originally Posted by Dave14867 View Post
    I tried creating an unbound field but when I input a qty for 1 part, it populates the same number for all of the parts.
    When you have a contol in continuous form, then you don't have a control for every row - you have a control which is displayed multiple times, so the control is displayed for every visible row in form. When the control is bound, then access manages what is displayed in every visible row, as displayed value is read from according record of form data source. When the control is unbound, access can display only what you entered lately - same for every visible row

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Can't figure out how to do this query
    By delorean004 in forum Queries
    Replies: 1
    Last Post: 12-22-2014, 04:33 AM
  2. Cant Figure This Out
    By tabbycat1234 in forum Forms
    Replies: 12
    Last Post: 07-27-2011, 02:19 AM
  3. can't figure out what i'm doing wrong
    By m0use in forum Queries
    Replies: 4
    Last Post: 06-16-2011, 09:18 AM
  4. Cannot Figure this query out
    By ryan1313 in forum Queries
    Replies: 6
    Last Post: 08-13-2010, 12:54 PM
  5. Can't Figure It Out!!
    By jdohio5 in forum Database Design
    Replies: 1
    Last Post: 05-04-2006, 06:49 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