Form is misunderstandig code

MissCLuvr

New member
Local time
Today, 13:49
Joined
May 16, 2001
Messages
9
I am getting the error message (The expression On Open you entered as the event property produced the following error: User-defined type not defined). The following is the code I used for the document:

---------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate

If Me.CheckTime.Value = 2 Then Exit Sub
If Me.CheckTime.Value = 1 Then Exit Sub


Dim strSQL As String, qdf As QueryDef
Dim ErrString As String, Count As Integer
Dim rst As Recordset

Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("TimeConflicts")

'Set query Parameters
qdf.Parameters("Forms!BroadcastSchedule!BroadcastDate") _
= [Forms]![BroadcastSchedule]![BroadcastDate]
qdf.Parameters("Forms!BroadcastSchedule!StartTime") _
= [Forms]![BroadcastSchedule]![StartTime]
qdf.Parameters("Forms!BroadcastSchedule!EndTime") _
= [Forms]![BroadcastSchedule]![EndTime]
qdf.Parameters("Forms!BroadcastSchedule!ScheduleID") _
= [Forms]![BroadcastSchedule]![ScheduleID]

Set rst = qdf.OpenRecordset()
rst.MoveLast
Count = rst.RecordCount
rst.MoveFirst
rst.Close

If Count <> 0 Then
ErrString = "Adding this record would cause a time conflict with " & Count & " other record"
If Count <> 1 Then ErrString = ErrString & "s"
ErrString = ErrString & ". Please resolve this conflict and try again!"
MsgBox ErrString, vbOKOnly, "Time Conflict"
Set dbs = Nothing
Cancel = True
Exit Sub
End If

Set dbs = Nothing

Exit Sub
Dim conflict As Integer
conflict = False
DoCmd.OpenQuery "Testing2", acViewNormal, acReadOnly
If Not IsNull(DLookup(BroadcastDate, "Testing2")) Then conflict = True
DoCmd.Close acQuery, "Testing2"

If conflict = True Then MsgBox "PROBLEM"

Err_Form_BeforeUpdate:
If Err.Number = 3021 Then Exit Sub
MsgBox Err.Number & Chr$(13) & Err.Description, , "Error"
Exit Sub
----------------------
Please help. If I need to send the database so that you can check it out, I will.
End Sub
 
Hi MissC,

at a blind guess you may have caused a namespace clash by using Count which is kind of reserved by Access. You also don't seem to have declared dbs anywhere.
If that isn't it please post back which line is highlighted in blue when the function is called.

I also noticed that there doesn't seem to be anyway of hitting the
Code:
Dim conflict As Integer
conflict = False
DoCmd.OpenQuery "Testing2", acViewNormal, acReadOnly
If Not IsNull(DLookup(BroadcastDate, "Testing2")) Then conflict = True
DoCmd.Close acQuery, "Testing2"
If conflict = True Then MsgBox "PROBLEM"
part of the routine

if you don't have any luck post back

HTH

Drew
 
Thanks for your help...but the freaky thing is that everything works from the replicated copy. When I transferred the replicated data to a new blank database to create a design master, in incurred that problem. The code has not changed and that is the only section of the database that does not work from the transfer. If there is a way to correct that problem let me know.

MissC
 

Users who are viewing this thread

Back
Top Bottom