Results 1 to 15 of 15
  1. #1
    Sneezy is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Mar 2020
    Posts
    7

    Trying to compile gives a Sub of Function not defined

    Hi there,



    It should probably be mentioned that I do not know how to use access but am investigating how to get a database running again that is broken down for my father.

    With the help of google I was able to get into Microsoft Visual Basic and tried to find the error. I THINK I fixed the reference error with the Microsoft Word 15.0 Object Library by changing it to 16.

    When I tried to compile the database with debug it said that a Sub or Function has not been defined..

    It popped up highlighting a bit of code called Form_Current.. for convenience, I have added the section that accompanies it.

    Code:
    Private Sub Bestelpunt_AfterUpdate()
    
        ' De gebeurtenisprocedure in Sub Form_Current uitvoeren.
        Form_Current
    
    
    End Sub
    Does anyone know what this means or how I fix this?

    Thanks in advance.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    you might get more and faster replies if you translate into the forum's native language - English. Otherwise you might get lucky if someone understands what you posted, or is willing to translate it for you.
    You could also check your references to see if any are marked as missing, as that is sometimes the cause. I can also take a guess - that the code is supposed to call the current event of the same form, in which case I think it ought to be Form_Current() or Call Form_Current()
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    alternatively, the form_current event is not there, perhaps deleted. You'll need to scan up and down the module or use ctrl-F to find it. Or you can use the dropdowns at the top of the vba window to find which object have events (Form in this case in the left dropdown, then find Current in the right dropdown). If there is an event it will be highlighted in bold

    Click image for larger version. 

Name:	Capture.PNG 
Views:	20 
Size:	19.9 KB 
ID:	41413

  4. #4
    Sneezy is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Mar 2020
    Posts
    7
    Quote Originally Posted by Micron View Post
    you might get more and faster replies if you translate into the forum's native language - English. Otherwise you might get lucky if someone understands what you posted, or is willing to translate it for you.
    You could also check your references to see if any are marked as missing, as that is sometimes the cause. I can also take a guess - that the code is supposed to call the current event of the same form, in which case I think it ought to be Form_Current() or Call Form_Current()
    Thanks for the response, I have translated the code for you as I have realized this could be handy.

    Code:
    Private Sub Bestelpunt_AfterUpdate()
        ' Execute the event procedure in Sub Form_Current.
        Form_Current
    
     End Sub
    Trying Form_Current() makes it red and gives an error that I have attached as well.



    Trying Call Current_Form removes () and when I try to compile it gives this error:



    The weird thing is that the sub seems to be empty as you can see in the attached image here below. I saw that other Form_Currents were the same, is this how it is normally coded?

    Quote Originally Posted by Ajax View Post
    alternatively, the form_current event is not there, perhaps deleted. You'll need to scan up and down the module or use ctrl-F to find it. Or you can use the dropdowns at the top of the vba window to find which object have events (Form in this case in the left dropdown, then find Current in the right dropdown). If there is an event it will be highlighted in bold

    Click image for larger version. 

Name:	Capture.PNG 
Views:	20 
Size:	19.9 KB 
ID:	41413
    Thanks guys, appreciate the responses. I have been able to find Form on the left side and Current in the right side. The thing is, it seems to be empty? I don't know if that is how it is supposed to be. I have attached an image for you guys to clarify.


  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    have been able to find Form on the left side and Current in the right side.
    the problem is if you have navigated to the form current event using the drop downs, it will automatically create a blank sub if one does not already exist. I said ' If there is an event it will be highlighted in bold' - so was it bold before you selected it?

  6. #6
    Sneezy is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Mar 2020
    Posts
    7
    Thanks for your reply, I believe it was not bolded before I selected it.

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    If your code had a call to a form event but that form event wasn't there, then I can see only 2 possibilities:
    a) someone intended to create one when they created code in the event that would call it but they forgot to create the current event, or
    b) it was there and somehow got deleted. That one might raise further issues as you try to fix things in this db as it would seem that whatever was supposed to happen will not. If you have older copy versions of the db, you might want to look at those to see if the current event for the form has code. If you do not have backup copies, you probably should be doing that going forward. It's how you fall back to something that was working when it gets badly messed up. This is one reason why it's good to split your db even if it's not shared and is on the same pc. Reverting to an older version will only replace the coded part; the data remains intact.

  8. #8
    Sneezy is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Mar 2020
    Posts
    7
    So I checked the old system (windows 98) (we want to transfer to new computer) and the strange thing is. On Access 2000 and the exact same database works. We can login and do everything. Only when transferred to a new computer with access 2016 it does not work and produces errors. Maybe this is a compatibility error?

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    I wouldn't call it a compatibility error, but it fits the scenario I'm seeing more an more posts about lately. That is, something that is 'improper' worked in older versions but 2016 seems to be more demanding. You are not the first to present what looks like something that is faulty yet worked until it was upgraded. Keep in mind that you have to be careful that you're talking about the exact same db. Nor would you be the first to say something broke when it was upgraded, only to discover that the upgraded file and the one that 'worked' are not the same file! Slight variations in their names or folder paths would do it.

  10. #10
    Sneezy is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Mar 2020
    Posts
    7
    Wait, folder paths matter? In the old computer it was on the G: drive where it is now on the C: drive. All else is the same because I just copied the whole folder out of the old computer.

    Edit: would getting access 2000 on the new computer(if that even works at all) solve the problem?

  11. #11
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    On Access 2000 and the exact same database works. We can login and do everything.
    what you haven't confirmed is whether on that old system you have code in the form_current event or even the Bestelpunt_AfterUpdate event

  12. #12
    Sneezy is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Mar 2020
    Posts
    7
    On Access 2000, a few forms popup when I use ALT + F11, but I can't find the "Product editing" Form at all. I'm still trying to see if there is a place that has all forms in an overview like in 2016. It doesn't really help the access 2000 is in another language that I can't read as well (but my father does).

    What I was able to do however, was login to the database and change a product. It got saved when we changed the amount.

    Edit:

    I have been able to find the form and confirmed that the form_current event and the Bestelpunt_AfterUpdate event are both identical in access 2000 database and the newer one. What does this mean?

  13. #13
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    what does it mean?
    perhaps the form is hidden? (go to file>options>current database, select navigation options, ensure display navigation pane is ticked then click on navigation options and ensure show hidden objects is also ticked) Or perhaps it didn't exist in the old system

  14. #14
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Wait, folder paths matter?
    Only in the context of which I was using it. I meant people posted a problem where something worked here but not there. Turned out the issue was that the "somethings" were not the same file.

  15. #15
    Sneezy is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Mar 2020
    Posts
    7
    Quote Originally Posted by Ajax View Post
    perhaps the form is hidden? (go to file>options>current database, select navigation options, ensure display navigation pane is ticked then click on navigation options and ensure show hidden objects is also ticked) Or perhaps it didn't exist in the old system
    I mean, I saw that both of the forms were identical in code or lack thereof. I was able to find it.

    Quote Originally Posted by Micron View Post
    Only in the context of which I was using it. I meant people posted a problem where something worked here but not there. Turned out the issue was that the "somethings" were not the same file.
    Ah I see, sadly this was not the case or the problem would have been solved haha!

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

Similar Threads

  1. Replies: 4
    Last Post: 10-16-2017, 09:09 AM
  2. Compile Error: Sub/Function not defined
    By TheKillerMonkey in forum Programming
    Replies: 12
    Last Post: 04-18-2016, 01:48 PM
  3. Compile Error Sub or function not defined
    By Ray67 in forum Reports
    Replies: 3
    Last Post: 07-02-2012, 04:11 PM
  4. Compile error: code or function not defined
    By GeorgeBrown in forum Access
    Replies: 1
    Last Post: 09-19-2011, 10:25 AM
  5. Compile error. Sub of function not defined
    By plavookins in forum Reports
    Replies: 7
    Last Post: 04-22-2011, 10:15 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