T
Ted
i'm using a2k and am starting to get the error in the heading about 'Item not
found in the collection' when i execute the following VBA code. i've read a
few questions posed of suppressing error messages in the queries group and
thought i'd finally 'gotten' how to pull this off w/o disabling all error
messages including the warnings, so i'll be darned if i understand why it
can't find/use the queries i've created.....i feel really certain that the
names i'm using for them are true to the ones under which i saved 'em. can
anyone offer a theory?
-ted
Private Sub Frame1_AfterUpdate()
Dim Response As Long
Dim Results As Integer
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Set db = CurrentDb
Select Case Frame1.Value
Case 1
Me.Onlistdate.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 6 _
Or myvarOldValue = 7 Then
DoCmd.RunCommand acCmdSaveRecord
Set qd = db.QueryDefs("Delete From Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
Case 2
Me.REgisteredDAte.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 6 _
Or myvarOldValue = 7 Then
DoCmd.RunCommand acCmdSaveRecord
Set qd = db.QueryDefs("Delete From Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
Case 3
Me.OnStudyDate.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 6 _
Or myvarOldValue = 7 Then
DoCmd.RunCommand acCmdSaveRecord
Set qd = db.QueryDefs("Delete From Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
Case 4
Me.TXEndedDate.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 6 Or myvarOldValue =
7 Then
DoCmd.RunCommand acCmdSaveRecord
Set qd = db.QueryDefs("Delete From Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
Case 5
Me.OffStudyDate.SetFocus
If myvarOldValue = 1 Or myvarOldValue = 2 Or myvarOldValue =
3 Or myvarOldValue = 4 _
And Not IsNull(OffStudyDate) And Not IsNull(SequenceNum)
Then
DoCmd.RunCommand acCmdSaveRecord
If Flag >= 0 Then
Set qd = db.QueryDefs("Append To Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
ElseIf myvarOldValue = 6 Or myvarOldValue = 7 And Not
IsNull(OffStudyDate) _
And Not IsNull(SequenceNum) Then
DoCmd.RunCommand acCmdSaveRecord
If Flag = 0 Then
Set qd = db.QueryDefs("Update Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
End If
Case 6
Me.LTFUDate.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 7 Then
DoCmd.RunCommand acCmdSaveRecord
If Flag = 0 Then
Set qd = db.QueryDefs("Update Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
End If
Case 7
Me.DateDth.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 6 Then
DoCmd.RunCommand acCmdSaveRecord
If Flag = 0 Then
Set qd = db.QueryDefs("Update Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
End If
Case Else
End Select
myvarOldValue = Me.Frame1
End Sub
found in the collection' when i execute the following VBA code. i've read a
few questions posed of suppressing error messages in the queries group and
thought i'd finally 'gotten' how to pull this off w/o disabling all error
messages including the warnings, so i'll be darned if i understand why it
can't find/use the queries i've created.....i feel really certain that the
names i'm using for them are true to the ones under which i saved 'em. can
anyone offer a theory?
-ted
Private Sub Frame1_AfterUpdate()
Dim Response As Long
Dim Results As Integer
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Set db = CurrentDb
Select Case Frame1.Value
Case 1
Me.Onlistdate.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 6 _
Or myvarOldValue = 7 Then
DoCmd.RunCommand acCmdSaveRecord
Set qd = db.QueryDefs("Delete From Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
Case 2
Me.REgisteredDAte.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 6 _
Or myvarOldValue = 7 Then
DoCmd.RunCommand acCmdSaveRecord
Set qd = db.QueryDefs("Delete From Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
Case 3
Me.OnStudyDate.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 6 _
Or myvarOldValue = 7 Then
DoCmd.RunCommand acCmdSaveRecord
Set qd = db.QueryDefs("Delete From Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
Case 4
Me.TXEndedDate.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 6 Or myvarOldValue =
7 Then
DoCmd.RunCommand acCmdSaveRecord
Set qd = db.QueryDefs("Delete From Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
Case 5
Me.OffStudyDate.SetFocus
If myvarOldValue = 1 Or myvarOldValue = 2 Or myvarOldValue =
3 Or myvarOldValue = 4 _
And Not IsNull(OffStudyDate) And Not IsNull(SequenceNum)
Then
DoCmd.RunCommand acCmdSaveRecord
If Flag >= 0 Then
Set qd = db.QueryDefs("Append To Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
ElseIf myvarOldValue = 6 Or myvarOldValue = 7 And Not
IsNull(OffStudyDate) _
And Not IsNull(SequenceNum) Then
DoCmd.RunCommand acCmdSaveRecord
If Flag = 0 Then
Set qd = db.QueryDefs("Update Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
End If
Case 6
Me.LTFUDate.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 7 Then
DoCmd.RunCommand acCmdSaveRecord
If Flag = 0 Then
Set qd = db.QueryDefs("Update Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
End If
Case 7
Me.DateDth.SetFocus
If myvarOldValue = 5 Or myvarOldValue = 6 Then
DoCmd.RunCommand acCmdSaveRecord
If Flag = 0 Then
Set qd = db.QueryDefs("Update Px's F/U--Edit Form")
qd.Execute dbFailOnError
End If
End If
Case Else
End Select
myvarOldValue = Me.Frame1
End Sub