Page 2 of 2 FirstFirst 12
Results 16 to 27 of 27
  1. #16
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by Rob66 View Post
    Thank you all
    I try to explain myself better
    Starting from the highest level to the lowest this is the sequence
    The Main Mask is a "Movement mask"
    By clicking in the body of the "Movement mask" in the properties window there is the name of another element called "UnderMaskMovement"
    Inside the UnderMaskMovement there is a submask called "Purchase documents"
    Which contains the field that I would like to insert the VBA code to is called “Contract” and its control source is called “Top Contract”
    So
    1. Mask: Navigation mask
    2. Form: SubformMovement
    3. Mask: Purchase documents
    4. Field: Contract


    I searched in this link: https://arrowdesign.ie/reference-sub...-in-ms-access/


    But I didn't find or understand the solution
    Thank you all
    So which is it, did not find or did not understand?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  2. #17
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    In your jargon a mask is a form? Seems like you're saying you have an issue referencing subforms and/or their controls.

    Syntax for referencing CONTROLS on subform:
    [Forms]![Main form name]![subform control name].[Form]![control name on subform]

    e.g.
    [Forms]![frmNP]![subNPfrm].[Form]![txtNPno]
    frmNP is main form name, subNPfrm is name of subform control on frmNP, txtNPno is the textbox control name. Leave off the [control name on subform] reference to refer to the form itself

    If you are using a built in navigation form, then:
    Syntax for referencing control on a form that is in a navigation form:
    Forms![main navigation form name]![NavigationSubform].Form

    Forms!frmNavigation!frmMain.Form!frmOvertime.Form. txtEmpID

    NOTE - the built in navigation form can only hold one form at a time. If you show formA then formB and try to reference formA you will likely raise an error because formA is now closed.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #18
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18
    Sorry but my job doesn't leave me much time to solve this problem.

    yes in my jargon a mask is a form

    I tried the solutions below from "https://arrowdesign.ie/reference-subform-properties-and-controls-from-parent-form-in-ms-access/" but without success

    As soon as I can I try again



    0) If Me![Documenti acquisti].Contratto.Value = "2270100831" Then


    1) [Forms]![frmNP]![subNPfrm].[Form]! [txtNPno]
    1) If Forms![Maschera di Spostamento]![Documenti acquisti].Form!Contratto.Value = "2270100831" Then




    2) Me!Subform_One.Form!Subform_Two.Form.RecordSource
    2) If Me![Documenti acquisti].Form.Contratto.Value = "2270100831" Then


    3) If Forms![Maschera di Spostamento]![Documenti acquisti].Form!Contratto.Value = "2270100831" Then




    4) Me!Subform_One.Form.RecordSource
    4) If Me![Documenti acquisti].Form.Contratto.Value = "2270100831" Then


    MsgBox "Attenzione! Per questo contratto č necessario fare un ulteriore MAP IPGM pari al 8,9% del consuntivo XXX.", vbExclamation, "Attenzione"
    end if
    end sub
    Thank you all

  4. #19
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    To re-iterate what Micron has said - (I started this post then had a few interruptions) I think it would help everybody if you used the correct terminology.
    I think what you are calling a mask is what we call a form. Similarly i think a submask is a called a subform.

    You should also make the distinction between fields and controls. Fields are the data storage columns in Tables. Controls display data or provide other interaction methods on forms.

    With a subform there are some very specific things to know.
    The subform consists of a control that hold the form - the Subform Control. It also has the form within it this is the Subform SourceObject.

    Access (very unhelpfully) by default, often calls the Subform Control the same as the form that it is holding.
    This can and often does lead to massive confusion.

    So I suspect you aren't referring to the controls correclty.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #20
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    It's still not clear if a navigation form is involved or not.
    Example 2 makes it look like there might be 2 subforms which could be nested or not.
    Note that if 2270100831 is number data type then it is wrong to put quotes around it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #21
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18
    with this code it works but it's for "Click"


    Private Sub Contract_Click()
    If Me.Contratto.Value = "2270100831" Then


    End If
    End Sub


    2270100831 is in text format

  7. #22
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Rob66,

    Do you have a solution or???
    You have a solution for "Click event", right?

    Can you tell us the status, and next steps (if any) in simple English---minimal database jargon?

  8. #23
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18
    I don't know but with the click event it worksClick image for larger version. 

Name:	Immagine 2023-08-04 190647.jpg 
Views:	17 
Size:	137.3 KB 
ID:	50599

  9. #24
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18
    I inserted the code in the specially created Module2


    Public Sub Contratto()
    If Forms![Maschera di spostamento].Form!SottomascheraSpostamento!Contratto.Value = "2270100831" Then
    MsgBox "Attenzione Per questo contratto č necessario un aumento del 8,9% del consuntivo.", vbCritical, "Attenzione"
    Else
    MsgBox "errore"

    End If
    End Sub




    trying the debug ...... all ok and exit the message boxes


    Then in the "Contratto" field at the Afterupdate event I inserted the call "Call Module2.Contract"


    but Afterupdate doesn't work if I put it in the DblClick event the code in Module2 is called and it works

    The "Contratto" is a field that is updated by filtering a query with a combo box and the query is the 'data source,


    I also tried to put in the vba also "Superior Contract" which is the data source of the "Contract" Field


    I also tried with the ……“On change” event


    I tried inserting a new textbox that takes the value from the "Contratto" field and inserting the Afterupdate event


    useless, it doesn't work

  10. #25
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    If I'm reading you correctly, you need to be aware that After updates events (in fact any events) don't fire when a value is altered by code, only when the form is interacted with.

    If you are changing one value in code simply either call the event you want to fire in the same code.
    If you are changing the value(s) by running a query then make the query do both updates?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  11. #26
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18
    the subform's data source is a query but "If you are changing values by running a query, do you make the query do both updates?" this solution had never happened to me, could you explain it better or show me a web resource
    Thank you

  12. #27
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    What I meant was if you have a form open - (We'll call it FormA) and you ran some code that changed a controls value (We'll call it txtDataField1) and you had some code in the AfterUpdate event of that control... That AfterUpdate event won't fire as a result of the value being changed.

    Does that make sense?

    So if your code did this:
    Code:
    Sub MyButtonCode
    
       Me.txtDataField1 =  999
    
    End Sub
    And your AfterUpdate event for did this:

    Code:
    Private Sub txtDataField1_After_Update
    
         MsgBox "Your DataField1 has been updated"
    
    End Sub
    So if you press the button, your data gets updated, but you never see the message box.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Replies: 2
    Last Post: 03-15-2018, 09:50 PM
  2. Replies: 2
    Last Post: 09-21-2017, 06:36 PM
  3. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  4. Replies: 3
    Last Post: 02-06-2015, 03:22 PM
  5. Replies: 21
    Last Post: 06-03-2009, 05:54 PM

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