Run time error 2001

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Anyone give me information on this error number - I keep getting it and i don't understand why

I've tried the help files but am drawing a blank everytime

Thanks
 
Can you describe what you're doing when the error occurs? And what code you
may be running when it occurs? Did you try to debug the code when the error
occurs and identify which line of code is causing the error?
 
----- Ken Snell wrote: ----

Can you describe what you're doing when the error occurs? And what code yo
may be running when it occurs? Did you try to debug the code when the erro
occurs and identify which line of code is causing the error

--
Ken here is a copy of the code i am usin

Private Sub ConfirmBooking_Click(

If IsNull(DLookup("[Aircraft]", "BookingDetails", "([Aircraft] = " & cboAircraft & " AND [HireDate] = #"
& cboHireDate & "#) AND ((#" & cboStartTime & "# BETWEEN [StartTime] AND [EndTime]) OR (#"
& cboEndTime & "# BETWEEN [StartTime] AND [EndTime]))")) The

statmen
els
statemen
end i

end su

The error occurs on the last line of the code and i can't figure out why

All i do is press the button then the error code comes up

That's it - hope it helps ask if you need more

Cam
 
What is the actual error message that you're getting? Error code 2001 is an
error generated by an application and doesn't have the same message all the
time.

I also assume that Aircraft, HireDate, StartTime, and EndTime are fields in
the table/query BookingDetails? Are the latter three formatted as Date/Time
fields?
--
Ken Snell
<MS ACCESS MVP>


Cam said:
----- Ken Snell wrote: -----

Can you describe what you're doing when the error occurs? And what code you
may be running when it occurs? Did you try to debug the code when the error
occurs and identify which line of code is causing the error?

--
Ken here is a copy of the code i am using

Private Sub ConfirmBooking_Click()

If IsNull(DLookup("[Aircraft]", "BookingDetails", "([Aircraft] = " &
cboAircraft & " AND [HireDate] = #" _
& cboHireDate & "#) AND ((#" & cboStartTime & "# BETWEEN [StartTime] AND [EndTime]) OR (#" _
& cboEndTime & "# BETWEEN [StartTime] AND [EndTime]))")) Then

statment
else
statement
end if

end sub

The error occurs on the last line of the code and i can't figure out why!

All i do is press the button then the error code comes up

That's it - hope it helps ask if you need more!

Cam
 
The Error message is Run-Time Error '2002
You cancelled the previous operatio

Correct they are all in the BookingDetails table and HireDate (formatted Short Date), StartTime and EndTime are formatted as Short Time

I also have a query set up called BookingQuery - but this is not called at any stage (i think) so it is not being used by the button command

Hope this helps yo

Ca
 
This error usually means that something in the DLookup function's syntax is
not correct. Things to look for:
(1) a misspelled field name
(2) using a field name that isn't in the table/query
(3) erroneous "WHERE" criterion statement

And, upon another reading of your DLookup, I think I see the problem. Remove
the [ ] characters from the "[Aircraft]" part of the DLookup syntax:

If IsNull(DLookup("Aircraft", "BookingDetails", "([Aircraft] = " &
cboAircraft & " AND [HireDate] = #" _
& cboHireDate & "#) AND ((#" & cboStartTime & "# BETWEEN [StartTime] AND
[EndTime]) OR (#" _
& cboEndTime & "# BETWEEN [StartTime] AND [EndTime]))")) Then

I believe that this is the problem.

--
Ken Snell
<MS ACCESS MVP>

Cam said:
The Error message is Run-Time Error '2002:
You cancelled the previous operation

Correct they are all in the BookingDetails table and HireDate (formatted
Short Date), StartTime and EndTime are formatted as Short Time.
I also have a query set up called BookingQuery - but this is not called at
any stage (i think) so it is not being used by the button command.
 
cam, if you're still working on this problem, i'll take a look at your db if
you want to send it to me - i can work on anything A97 or newer. if you
decide to see if i can help, do the following:

remove propriety data from a copy of your db, entering a few "fake" records
for testing data.
compact the db.
create a self-extracting zip file, if possible (i don't have WinZip up and
running yet).
attach to an email that references this newsgroup in the subject line, and
send to ttaccessKillallspam1 at yahoo dot com, removing the
Killallspam text only. if i can make it work, i'll return the "fixed" db to
you so you can see how i did it.

tina
 
In the domain functions, you don't use [ ] characters around field names or
around table/query names in the first two arguments of the function.

Without knowing more details about your database, I can only point again to
the list that I'd provided earlier. If you can provide more info, it may
help shed light on what is going wrong.
 
Here is the code as it is on my button - all names are as here
---------------------------------------------
Private Sub ConfirmBooking_Click(

If IsNull(DLookup("[Aircraft]", "BookingForm", "([Aircraft] = " & cboAircraft & " AND [HireDate] = #" & _cboHireDate & "#) AND ((#" & cboStartTime & "# BETWEEN [StartTime] AND [EndTime]) OR (#" &
cboEndTime & "# BETWEEN [StartTime] AND [EndTime]))")) The

txtConfirm.Text = "Your booking is confirmed" ' Dlookup returns Null = No record foun
Els
txtConfirm.Text = "Please Choose another Aircraft, Date, Time" 'DLookup found a record
End I

End Su
------------------------------------------------------
Here are the fields from my table [BookingDetails]

Timesheet ID (primary Key) = Autonumbe
HireName = Numbe
Aircraft = Tex
HireDate = Date/Time (formatted short date
StartTime = Date/Time (formatted short time
EndTime = Date/Time (formatted short time
-----------------------------------------------------

I have 2 additional tables a MembersDetails and an AircraftDetails. I also have a BookingQuery set up

What I am trying to achieve is that once the user presses the confirm booking button then the code checks the fields [Aircraft], [HireDate], [StartTime] and [EndIte] to see if there is any duplication

If there is duplication you get one message (Not Null) in a text box and if there is duplication (Null) then you get another message. [i may remove this and have a message bos instead - not decided yet

As far as i am aware all dates and times are delimite

Hope that helps you to understand what i'm trying to do

Cam
 
Not sure if it's the copy/paste or if what you've posted is the actual code,
but, assuming the latter, you don't have a space between the _ character and
cboHireDate on the first line. This is different from what you'd posted
initially where it appeared that the cboHireDate started a new line?

Also, you state that Aircraft is a text field. That means that you need to
delimit the value coming from cboAircraft with ' marks in the first part of
the criteria string.

Thus, try this (note that I started new line for cboHireDate and that I've
put ' character on either side of cboAircraft concatenation):

If IsNull(DLookup("[Aircraft]", "BookingForm", "([Aircraft] = '" &
cboAircraft & "' AND [HireDate] = #" & _
cboHireDate & "#) AND ((#" & cboStartTime & "# BETWEEN [StartTime] AND
[EndTime]) OR (#" & _
cboEndTime & "# BETWEEN [StartTime] AND [EndTime]))")) Then

--
Ken Snell
<MS ACCESS MVP>

Cam said:
Here is the code as it is on my button - all names are as here
cboAircraft & " AND [HireDate] = #" & _cboHireDate & "#) AND ((#" &
cboStartTime & "# BETWEEN [StartTime] AND [EndTime]) OR (#" & _
cboEndTime & "# BETWEEN [StartTime] AND [EndTime]))")) Then

txtConfirm.Text = "Your booking is confirmed" ' Dlookup returns Null = No record found
Else
txtConfirm.Text = "Please Choose another Aircraft, Date, Time" 'DLookup found a record.
End If

End Sub
-------------------------------------------------------
Here are the fields from my table [BookingDetails]:

Timesheet ID (primary Key) = Autonumber
HireName = Number
Aircraft = Text
HireDate = Date/Time (formatted short date)
StartTime = Date/Time (formatted short time)
EndTime = Date/Time (formatted short time)
------------------------------------------------------

I have 2 additional tables a MembersDetails and an AircraftDetails. I also have a BookingQuery set up.

What I am trying to achieve is that once the user presses the confirm
booking button then the code checks the fields [Aircraft], [HireDate],
[StartTime] and [EndIte] to see if there is any duplication.
If there is duplication you get one message (Not Null) in a text box and
if there is duplication (Null) then you get another message. [i may remove
this and have a message bos instead - not decided yet)
 
Back
Top