Results 1 to 6 of 6
  1. #1
    sreee0009 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    6

    calling function from form's code to module section

    hi i have a form which has code written in code module function(x)


    now when i try to call this function(x) in my specific module it throws me sub or function not defined !! how can i correct this error? tried by changing it into public and removing private didn't work.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    The code is in the form's module? Or a general module? Your function is declared with a name of 'function' ? Function is a reserved word and should not be used as name for anything.
    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.

  3. #3
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Should probably post the function and the call and be specific about which code is on what. I take this to mean that OP is trying to run code in a form module by calling it from a standard module. While you call some form events and procedures from within the same form, I'm pretty sure the scope of that code isn't available from outside the form. Same goes for a report. If this is what's going on, it's not an error at all (at least on the part of Access).
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    It is possible to call form module procedures from another module. Examples:

    Call Forms("SampleManagement").SelectRecord

    Call Forms("SampleManagement").LabReport(strLabNum, "Transfer")

    I have a main form call procedures in its subforms:

    If .tbxSet Like "*1*" Then Call .ctr1.Form.SaveData
    If .tbxSet Like "*2*" Then Call .ctr2.Form.SaveData
    If .tbxSet Like "*3*" Then Call .ctr3.Form.SaveData
    If .tbxSet Like "*P*" Then Call .ctrProctor.Form.SaveData
    If .tbxSet Like "*V*" Then Call .ctrVibratory.Form.SaveData
    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.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    These are user defined events, yes? By While you call some form events... I meant events belonging to the form (and it's controls) itself, not UDF's.
    Like a button click event.
    It's late and I shouldn't be trying to make a lot of sense right now. Later!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Well, they aren't events, just procedures. Can also call form and control event procedures as long as they are not declared Private, even a button Click event. Same for my user defined procedures, can't be Private. It's all just code.
    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.

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

Similar Threads

  1. code error is calling a form
    By Jen0dorf in forum Access
    Replies: 2
    Last Post: 03-10-2016, 10:14 AM
  2. Replies: 3
    Last Post: 06-24-2015, 06:25 PM
  3. Calling a Private Function from Another Form
    By MintChipMadness in forum Programming
    Replies: 1
    Last Post: 01-07-2013, 12:08 PM
  4. Calling a Function From A Form.
    By ksmith in forum Access
    Replies: 2
    Last Post: 06-07-2012, 02:23 PM
  5. Calling A Module Function To Open A Form
    By orcinus in forum Modules
    Replies: 3
    Last Post: 09-29-2010, 04:43 PM

Tags for this Thread

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