There is no need to create variables for these simple examples.
But it might be a good idea. Sometimes you want to add more code that refers
to the form once it's open, so you can do that with:
Forms(stDocName)
Other times, the criteria can get quite complex (several clauses, even
subqueries that look up values in tables that are not in the form's
RecordSource). You can simplify the debugging process by adding the line:
Debug.Print stLinkCriteria
My personal preference is that I use a variable for the WhereCondition most
of the time, but only use one for the form name if I will refer to it more
than once.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"OM" <OM@youknowwhere.comwrote in message
news:45**********************@news.optusnet.com.au ...
Can someone tell me why, in Event Procedures that are generated by MS
Access, (say to open a form, as below), the form name is entered as a
variable stDocName. Why not just use the form name itself ? Or is there a
good reason not to? I would guess the same arguments apply to
stLinkCriteria ?
ie why
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmIncidentHeader"
DoCmd.OpenForm stDocName, , , stLinkCriteria
rather than
DoCmd.OpenForm frmIncidentHeader, , , fldQNIEV=100
Thanks folks
Rob Lepper