Sub proecedure wont run

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there

I am comfortable with Excel VBA, but have a problem running my first sub
procedure in Access. I am following a tutorial book, the sub is very simple,
but when I position the cursor inside the sub and click on Run I get a prompt
for macro name as if the VBE does not recognise the sub as capable of being
run ...

Public Sub OpenClientForm()
' Open the Client form
DoCmd.OpenForm "Clients"
Debug.Print 'The form is open'
End Sub

Is this an installation error, or a security problem or something?
I am running MS-Access 2002.

Any suggestions gratefully received!
 
Problem sorted - the sub procedure was contained in the code section of a
form and not in a general module. Once the sub had been moved to a module, it
worked okay
 
Matthew said:
Problem sorted - the sub procedure was contained in the code section of a
form and not in a general module. Once the sub had been moved to a module, it
worked okay

If you wish to execute a procedure directly from the Database Window,
you can define (in your Module) a public function which calls it, and
then define a Macro that includes a RunCode action to execute your
function. That can be a convenient way to debug parts of your code.

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
 
I have a similar problem, but different symptoms. I can launch my app from
the database window by double-clicking on the Main form icon, but none of my
breakpoints in the code window hit. If I select the Main() sub in my modMain
(which loads and launches the frmMain) in the VB Editor Code Window and
select Run from the Run menu, nothing happens. No form launches, no error
messages, nothing. If I don't have a sub or anything selected and click the
Run icon in the VB Editor, it asks for a macro to run.

I KNOW that I am being incredibly obtuse about something here, but I just
can't seem to figure out how to get into the debugger, or to start the app in
a "debug" mode.

This is Access 2002 from Office XP on a Dell Inspiron 1100 running Windows
XP SP2. All OS and Office updates are applied. TIA.

Paul
 
Back
Top