16

Why do I get a

"Return without GoSub"

error when using subforms in Access 2007?

Sinister Beard
  • 3,570
  • 12
  • 59
  • 95

5 Answers5

25

This can occur when there is a Form_Load() event in the subform, but not the main form. Try adding an empty Form_Load() event to the main form.

Sinister Beard
  • 3,570
  • 12
  • 59
  • 95
  • 2
    There is no problem with having form load events in both the form and the subform, there is a problem with having subform load events that refer to the main form because the subform loads before the main form. – Fionnuala Jul 13 '12 at 09:38
  • 1
    Genius, I removed the Form_Load() event and it worked like a charm :) – Tony Jun 03 '16 at 12:03
  • 1
    Adding an empty Form_Load() solved the problem for me - what a strange issue – arbitel Oct 20 '16 at 11:48
  • @arbitel I think Fionnuala is write about the root of the problem, though. There's probably a bigger issue that also needs addressing. – Sinister Beard Oct 20 '16 at 14:19
  • 1
    There was indeed haha - it made itself apparent about an hour after I posted this. Long story short, it involved my lack of understanding with INNER/LEFT/RIGHT joins but I was able to fix – arbitel Oct 20 '16 at 15:16
  • 1
    Wow. That fixed it for me too... for no good reason whatsoever. I didn't have Load() defined for either the master or subform, but defining both made the problem go away. – Pete Magsig Mar 01 '17 at 23:29
7

The most likely reason for this error is that the project has become corrupt. You should decompile, instructions are here: Debug a bad DLL calling convention error

First, ensure that you have switched off Name Autocorrect: http://allenbrowne.com/bug-03.html and ensure that you are not missing any references.

Community
  • 1
  • 1
Fionnuala
  • 90,370
  • 7
  • 114
  • 152
0

I found a useful solution (in my case) for that same issue at http://www.fmsinc.com/microsoftaccess/performance/decompile.asp . It worked as a charm for me. HTH Phil

  • 2
    If possible, it's best to include a description of the answer, in case the link goes dead one day... – StackExchange What The Heck Dec 20 '13 at 19:24
  • 1
    This is copied from the link above: To decompile your database, follow these steps From the Windows, Start, Run command line, type: msaccess.exe /decompile where msaccess.exe includes the complete path. For example, for Access 2016: C:\Program Files\Microsoft Office\Office16\MSACCESS.EXE /decompile From Access open the database you want to decompile (with trusted authority for Access 2003 or later) Open up any module. Compile it via Debug, Compile, then File, Save. Go back to the database and Compact it. The database size should be reduced and errors related to the VBA code gone. – LauraNorth Sep 29 '16 at 13:38
0

Performing a decompile of the VBA code and recompiling followed by compacting my database resolved the issue for me.

c_rugby
  • 19
0

I had something similar (not specifically in VBA, but with using a form to update a subform). I just added a "StopAllMacros" step at the end of the screen updating object and it seemed to work.

enter image description here

Chris
  • 25
  • 5