-----Original Message-----
Dave said:
Dim MyNumber As String
MyNumber = [Form_AllMaintenance].PMNumber
If Me.DaysOverDue.Value > 0 Then
DoCmd.OpenForm "TasksOutstanding", acNormal, , MyNumber =
[Form_TasksOutstanding].PMNumber
Else
DoCmd.OpenForm "TasksDue", acNormal, , MyNumber =
[Form_TasksDue].PMNumber
End If
If the number of days over due is bigger than 0
(ie over due) then it should open the TasksOutstanding
form on that record and the same for if it is not over
due, but it should open the workordersdue form. Hope this
is enough.
Dave.
You're not using the right syntax for the WhereCondition argument of the
OpenForm method. This argument should be expressed as a string; plus,
your reference to the module of the form to be opened (e.g.,
"[Form_TasksOutstanding]") is unnecessary, and is probably actually
causing the forms to be opened even before the OpenForm method executes.
I believe what's been happening is that the expressions such as
MyNumber = [Form_TasksOutstanding].PMNumber
have had the effect of opening (hidden) the form named, then comparing
the value of the PMNumber field on that form to MyNumber, arriving at a
value of True (-1) or False (0), and then setting the opened form's
Filter to the string representation of that True/False value.
Try this revised version instead:
'----- start of revised code -----
Dim MyNumber As String
MyNumber = [Form_AllMaintenance].PMNumber
If Me.DaysOverDue.Value > 0 Then
DoCmd.OpenForm "TasksOutstanding", acNormal, , _
"PMNumber = " & MyNumber
Else
DoCmd.OpenForm "TasksDue", acNormal, , _
"PMNumber = " & MyNumber
End If
'----- end of revised code -----
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
.