Link to home
Start Free TrialLog in
Avatar of Anthony Farinholt
Anthony Farinholt

asked on

Access2017 parameter goes NULL

Using docmd.openform( argument ), with a non-null argument...when single step debugger to the open form it shows the argument as null. Anyone seen things like this? If so, please help!
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Not sure I understand the question.   The first argument is the form name, but you imply that the form is opening.

What is it your trying to pass?   Unless you use named arguments, you need to supply all the parameters, and openargs is last.

Jim.
Make sure that your form name is in quotations -- otherwise it may appear like an undeclared variable (null):

' Use quotes around the first argument (form name)
' Example 1
docmd.openform( "argument" ) 
' Example 2
docmd.openform( "MyFormName" )

Open in new window


Alternatively, declare and set a string variable for your form name, and then use the variable name without quotes:
' Example 3
Dim strFormName as string
strFormName = "MyFormName"
docmd.openform( strFormName  )

Open in new window


And as a good practice you should always use Option Explicit at the top of your code modules, right under option Compare Database.  This forces you to declare all of your variables... which may help in debugging issues like this:

Option Compare Database
Option Explicit

Open in new window

Give an example of DoCmd.OpenForm

And what are you testing in the OpenForm event?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.