Okay, both Allen and I missed a period, which is why you're getting the
error message. Since PgOtherDates is the name of a Page control on the form,
it should have been:
..TabCtl90 = .PgOtherDates.PageIndex
However, it turns out Allen was incorrect that that would do what you want.
Instead, use
DoCmd.OpenForm "frmSiteConstruction_Information", datamode:=acFormEdit, _
wherecondition:="[SITE NUMBER]='" & Me.[SITE NUMBER] & "'", _
OpenArgs:=Me.Name
With Forms("frmSiteConstruction_Information")
.PgOtherDates.SetFocus
End With
Sorry about that.
Let me add, though, that the reason you got that particular error message is
because you haven't told Access to require that all variables be declared.
Look at the top of your module. It should have the line
Option Explicit
there (either the 1st or 2nd line)
If you had that line there, you would have got a "Variable not defined"
error instead, because Access would have assumed PgOtherDates was a
variable.
Go into the VB Editor and select Tools | Options. Look on the Editor tab.
The checkbox "Require variable declaration" should be checked. That will
ensure that Option Explicit gets added to all future modules.
(Unfortunately, you'll have to go and add it manually to all the existing
modules). While it may be a pain having to correct any oversights in your
code, having that option set will ultimately save you hours of time.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Ayo said:
I am still getting the same error message and it is not working.