to open a form in VBA why do i need to dimension 2 stringvariable?

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

When i want to open a report in a form (with VBA) i only
need to dimension 1 string variable

When i want to open a form instead of a report i need to
dimension 2 stringvariable (see down here)

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "University"
DoCmd.OpenForm stDocName, , , stLinkCriteria

I do not understand what the second string variable
(stLinkCriteria) does or stand for.

Thanks
 
Peter said:
When i want to open a report in a form (with VBA) i only
need to dimension 1 string variable

When i want to open a form instead of a report i need to
dimension 2 stringvariable (see down here)

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "University"
DoCmd.OpenForm stDocName, , , stLinkCriteria

I do not understand what the second string variable
(stLinkCriteria) does or stand for.

It's entirely unnecessary, unless you intend to use it to pass criteria
for the form. You could just as easily write:

Dim stDocName As String

stDocName = "University"
DoCmd.OpenForm stDocName

For that matter, you don't really need stDocName, either. You can just
write this:

DoCmd.OpenForm "University"

The command button wizards crank out this code from templates that leave
"blanks" for the common variables. When you're writing your own code,
you can dispense with them.
 
Back
Top