Dim PDate as String
Dim LBMonth as Variant
AC = Me.OpenArgs 'Which is a lookup value from the original form. In
this example AC=1
lbMonth = "Forms![Discipline Project Input Screen]!" & "lblMonth" &
Right(AC, 1)
PDate = lbMonth.caption
Call OpenF(JEProj, PDate)
When I run the code I receive "Runtime Error 424. Object required.
What line is causing the error?
PDATE.
A few things I would make sure of...
1) Is AC a variant? If for any reason OpenArgs is not used or supplied
it will be Null and this code will fail on that. If a variant is not
used, it would be wise to trap form Nulls
2) Is the OpenArgs value alwasy going to be a one digit number? Is the
entrie OpenArgs value going to used in the control Assignment or just
the right-most character? If the whole argument is used then you don't
need to use the Right function.
3) LBMonth is shown as a variant. Are you attempting to assing the
control to this variable or its value. If the control, you should be
setting it as a control intead of a variant. When assigning objects to
a variable you need to use the Set statement. The fact that the
Caption property is not capitalized should indicate that the control
reference is not valid...
Dim LBMonth As Control
Set LBMonth = Forms("Discipline Project Input
Screen).Controls("lblMonth" & Right(AC, 1))
PDate = LBMonth.Caption