Results 1 to 14 of 14
  1. #1
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18

    Problem with macros and access

    HI




    I installed office 365 on windows 10 64 bit and excel macros I can run step-by-step with the F8 key while access macros cannot be done with the F8 key.
    If I open the "Debug" menu and press "Run F8" nothing happens
    and from the "Run" menu I press "run Sub/Userform F5" the macro selection mask opens but it is empty
    Thank you all for the replies and help me

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Are your Access files in a Trusted Location? There is no warning at the top of the application window that says code is disabled?
    FYI in Access, macros are an entirely different thing to Excel macros so I think the terminology matters here. Excel macros look like code procedures in Access. I'm assuming that for Access, you are trying to run code procedures and not macros.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18
    Yes the location is C:\
    No nothing no warning at the top of the application window that says code is disabled
    sorry ... vba procedure

    Thank

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    It would be quite odd to make C a trusted location unless maybe you mean a Trusted Root Certificate, and that's not the same thing.
    Out of curiosity I tried it and I'm surprised that it's possible.
    Anyway, some procedures cannot be run with F5 or F8 and AFAIK, that is not limited to Access. Perhaps provide an example of a sub that you cannot run but you think it should be possible.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    If it is form code then, put a breakpoint in an event procedure and use whatever runs that procedure to start the code.
    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

  6. #6
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18
    I'm sorry I'm a beginner......the code doesn't work because it's inserted in a form, if I insert it in a form it works
    Thank you all

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Then I think it's time to show the code. Please enclose it in code tags (use # button on posting toolbar) to maintain indentation and readability.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18
    With microsoft access 365 in a Navigation Form I have a sub-form called "ResiduiContratti" which has a field called "FinevaliditaCTRR" type date dd/mm/yy.
    I'm trying to create a button that with a vba macro filters the "FinevaliditaCTRR" field with the date greater than "Today"
    But I get a message "Run-time error 2465" "Application or object defined error".
    Here the vba code

    Code:
    Dim strFiltro As String
        Dim dtOggi As Date
        
        dtOggi = Date
        strFiltro = "[FinevaliditaCTRR] > " & CStr(CLng(Date))
        Forms("Maschera di Spostamento").Forms("ResiduiContratti").Controls("FinevaliditaCTRR") = strFiltro
        Forms("Maschera di Spostamento").Forms("ResiduiContratti").Form.Controls("Fine validità CTR R").FilterOn = True
    Thank you

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    So now it's about a nav form? Cannot decipher everything from that example so here's nav form reference syntax
    Code:
    Forms![main navigation form].[NavigationSubform].Form
    If you left default nav subform name alone, it is likely named "NavigationSubform" [main navigation form] represents the name of the form that everything else is on.

    Here's how if you add a control name reference for txtEmpID
    Code:
    Forms![main navigation form].[NavigationSubform].FormtxtEmpID
    Last edited by Micron; 03-13-2023 at 11:18 AM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18
    Hello and thanks
    I tried this code
    Code:
    Dim Filter As String
    
    
    filter = "[CTR R Validity End] > " & CStr(CLng(Date))
    
    
    Forms![Movement form].Form!Movement Subform.Forms!ResiduiContracts![CTR R Validity End] = filter
    
    
    Forms![Displacement Form].Forms!Displacement Subform.Form!Contract Residuals.[R CTR Validity End].FilterOn = True


    but it sends back the message: run-time error 438
    property or method not supported by the object

  11. #11
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    So many things not right


    • you can't filter a control, you filter the form.
    • If you have spaces in your names, you must surround with square brackets (Movement Subform, Displacement Subform)
    • You appear the be trying to set the filter to one thing, the set filter on on another.
    • It is a very bad idea to name things with reserved words - such a Filter
    • Dates are actually stored as numbers and need to be surrounded with the # character and the date string needs to be in the US format of mm/dd/yyyy or the SQL standard of yyyy-mm-dd. But in this case you can just pass the date function as part of the string


    Strongly recommend you copy/paste your actual code rather than what appears to be free typed (you have dimmed Filter, but assign a string to filter, because the first letter is a different case this implies you are freetyping)

    Based on what you have provided, this might be what you are looking for
    Code:
    Dim strFilter As String
    
     strFilter = "[CTR R Validity End] > Date()"
    
    'or you can use
    'strFilter = "[CTR R Validity End] > #" & format(Date(),"yyyy-mm-dd") & "#"
    
    Forms![Movement form].Form![Movement Subform].Forms!ResiduiContracts.Filter =  strFilter
    Forms![Movement form].Form![Movement Subform].Forms!ResiduiContracts.FilterOn = True
    
    'or perhaps you need
    Forms![Displacement Form].Forms![Displacement Subform].Form!Contract Residuals.Filter=strFilter
    Forms![Displacement Form].Forms![Displacement Subform].Form!Contract Residuals.FilterOn = True

  12. #12
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18
    Thanks CJ_London

    The [Fine validità CTR R] is a Field

    the code i put was translated from italian to american, however i tried your suggestion

    Code:
    Dim strFilter As String
    
    
    strFilter = "[Fine validità CTR R] > Date()"
    
    
    'or you can use
    strFilter = "[Fine validità CTR R] > #" & Format(Date, "yyyy-mm-dd") & "#"
    
    
    Forms![Maschera di spostamento].Form![SottomascheraSpostamento].Forms!ResiduiContratti.[Fine validità CTR R].Filter = strFilter 'Access debugging stops at this statement with run-time error 438 property or method not supported by the object
    Forms![Maschera di spostamento].Form![SottomascheraSpostamento].Forms!ResiduiContratti.FilterOn = True
    
    
    'or perhaps you need 
    'if I try these instructions Access does not find ResiduiContratti
    'Forms![Maschera di spostamento].Forms![SottomascheraSpostamento].Form!ResiduiContratti.Filter = strFilter
    'Forms![Maschera di spostamento].Forms![SottomascheraSpostamento].Form!ResiduiContratti.FilterOn = True
    thank you very much again......... it takes a lot of patience

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    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

  14. #14
    Rob66 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2023
    Posts
    18
    Quote Originally Posted by welshgasman View Post

    thank you very much,
    i will succeed

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

Similar Threads

  1. Replies: 4
    Last Post: 02-19-2016, 03:13 PM
  2. Replies: 1
    Last Post: 09-01-2015, 02:01 PM
  3. Access VBA and Macros
    By orangeman2003 in forum Programming
    Replies: 3
    Last Post: 09-09-2014, 01:29 PM
  4. Access macros
    By mamig in forum Access
    Replies: 2
    Last Post: 01-09-2010, 11:26 AM
  5. Replies: 0
    Last Post: 03-27-2008, 08:20 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