Results 1 to 3 of 3
  1. #1
    JBros is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    21

    Linking Id's through a Macro in Access

    I'm trying to make a relation between two tables to show information through a Macro. To give a perspective, I have a table called 'Companies' where there are all the information needed. I've made a 'Home' form where there is a SubForm to show the companies.




    My idea is that the field 'Companies' of this subform, which shows the name of the company, could link to another subform called 'Companies Detail' through the ID.
    So far, I've done this to the macro (the id field is called Id_company).:
    The syntaxis is in spanish so sorry for that and hope this could be understable:


    Code:
    If EsNulo([Formularios]![Consulta para Detalle Empresas]![Id_company])
    then do a BIP.


    Code:
    If NoEs EsNulo([Formularios]![Consulta para Detalle Empresas]![Id_company])
    then
    Code:
    OpenForm
    and in the conditions on
    Code:
    WHERE
    I've written:
    Code:
    ="[Id]=" & [Id_company]


    The idea is that when you click on the name of the company in the Home form, this redirects to the 'Consulta para Detalle Empresas' form. I can't get it working. I'd like to hear opinions and I'll share more information and do my best to make it understandable if it isn't at all. Thank you in advance.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Normally, you'd open a parent form to show a single record Company rec.:OpenForm "frmCo",,,"[id]=" & me.id
    The subForm would be the company detail, linked on the ID field.:
    the only code would be to open parent form from the main form.
    but,
    You have a main form with 2 sub forms. (Sounds busy) but the links are the same,
    the subForm Co names, and the subForm CoDetails.
    subform Co name would have no link,
    subform CoDetail would have a link to subForm Co ID.

  3. #3
    JBros is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    21
    Thank you for the reply, I'm gonna check it right now. However, to give you an idea, I'd like to do something like in the Northwind sample database, with a main 'Home' form and links to detail as in the Northwind there are the inventory files.

    Click image for larger version. 

Name:	Captura.PNG 
Views:	7 
Size:	85.5 KB 
ID:	29496

    So I mean those links that link to specific form for each product, in Northwind's example. Thank you again.

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

Similar Threads

  1. Linking Id's through a Macro in Access
    By JBros in forum Access
    Replies: 36
    Last Post: 07-20-2017, 11:20 AM
  2. Replies: 3
    Last Post: 05-28-2017, 07:36 PM
  3. Replies: 1
    Last Post: 01-21-2015, 02:02 PM
  4. Access macro vs. excel macro
    By twckfa16 in forum Macros
    Replies: 3
    Last Post: 01-07-2015, 03:44 PM
  5. Replies: 0
    Last Post: 03-04-2011, 10:28 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