Reply
Blank Fields
Old 07-22-2004, 03:43 PM Blank Fields
Novice Talker

Posts: 5
Hello everyone.

I am creating a website that contains an events list. The events have 5 fields: Title, Location, Description, Start, and End date. If the event is only one day, the user leaves the end date field blank (and the rest of the site does the rest). Here's my problem.

If the user creates an event, and then goes back to edit it, the submission script is supposed to tell whether the end date field is left blank or not. If it was not left blank, it is supposed to take the end date field, and overwrite what was already there. If it was left blank, another query string will make it null. Here's my scripting.

Code:
<%
if(Session("UserID")==null)
	Response.Write("Administrative access only.  Please redirect to the login page.");
else
{
	var EventID=Number(Request.Form("EventID"));
	var Title=String(Request.Form("Title"));
	var Location=String(Request.Form("Location"));
	var Body=String(Request.Form("Body"));
	var Start=Request.Form("Start");
	var Stop=Request.Form("End");
	var PageRedirect;
	 
	if(Title.ActualSize==0 || Body.ActualSize==0 || Start.ActualSize==0)
	{
		Response.Write("The creation of your event could not be completed because a field was left blank.");
		PageRedirect="EventAdd.asp";
		%><!--#INCLUDE file="Includes/Redirect.inc"//--><%
	 }else
	 {
	 	if(Stop!=null)					 
	 		Application("CBEA").Execute("UPDATE [Events] SET Events.evTitle="+fixApostrophes(Title)+", Events.evLocation="+fixApostrophes(Location)+", Events.evDescription="+fixApostrophes(Body)+", Events.evStart=#"+Start+"#, Events.evEnd=#"+Stop+"# WHERE [Events].[evID]="+EventID);
		else
			Application("CBEA").Execute("UPDATE [Events] SET Events.evTitle="+fixApostrophes(Title)+", Events.evLocation="+fixApostrophes(Location)+", Events.evDescription="+fixApostrophes(Body)+", Events.evStart=#"+Start+"#, Events.evEnd=null WHERE [Events].[evID]="+EventID);
		
		Response.Write("Your event has been successfully posted to the events list.");
		PageRedirect="EventView.asp";
		%><!--#INCLUDE file="Includes/Redirect.inc"//--><%
	 }
}
%>
The error I am getting is this:

Code:
Microsoft JET Database Engine- Error '80040e07' 

Syntax error in date in query expression '##'. 

E:\CBEA\Inetpub\Admin\EventEdit_action.asp, line 56
Although that is the error I am getting, the real error is in the if-then-else statement. If the field was left blank (like the error is saying) then it should be going to the else query string, but it's not. Any ideas?
technoblinc is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-22-2004, 03:52 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
It would appear as though the format of the Start and Stop values are not in a form that Access is expecting for the Date formats.

I know #7/22/2004# is acceptable, for example. Have you confirmed that the values you're getting from the form are in such a format?
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 07-22-2004, 04:03 PM Re
Novice Talker

Posts: 5
I know that the dates are in the correct format. They are in the same format that I am using for adding the event to the database, in a different page.

The error is in my coding, with the if-then-else statement, but as a result from my error, the script is returning a query string error, because the field was left blank on the submission page, intentionally, though.
technoblinc is offline
Reply With Quote
View Public Profile
 
Old 07-22-2004, 04:21 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Oh, I see your issue. You are right. The syntax for if then is incorrect.

In VB, the syntax looks like this

If a=b Then
......
Else
.....
End If

There are no braces and no relational operators such as ||. Use the keywords Or and And to test relationships. Parenthesis can be used, but they are not part of the If itself -- use them for grouping as in

If (a=b) And (c=d)
............
End If
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 07-22-2004, 04:29 PM
Novice Talker

Posts: 5
Sorry, forgot to mention what was really going on.

I'm scripting in ASP Javascript. I know all of my syntax is correct since I've been using the same stuff for a couple years now .
technoblinc is offline
Reply With Quote
View Public Profile
 
Old 07-22-2004, 04:52 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Ah, I see. Sorry, I'm not familiar with that syntax.....
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 07-22-2004, 05:10 PM
Novice Talker

Posts: 5
Everything pretty much works the same, it's just the way you write it.
technoblinc is offline
Reply With Quote
View Public Profile
 
Old 07-22-2004, 05:50 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
techno,

Looking at your error,

Quote:
Syntax error in date in query expression '##'.
It really looks like one of your values is coming up empty string.
So in the code snippet:

Code:
Events.evEnd=#"+Stop+"# WHERE
If Stop were to be an empty string, that's the only explanation I can imagine where you would get the error mentioned with '##' specifically mentioned. To get that value, Stop would have to be empty. But you said you confirmed that the Start and Stop values are valid, so.....

Do you get the error everytime?
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 08-11-2004, 04:57 AM
wbmstr2good's Avatar
Average Talker

Posts: 22
I have written software for exactly your purpose (events manager). If you would like to take a look at mine and see if you like it, I'm sure we can work something out.
wbmstr2good is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Blank Fields
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.17911 seconds with 12 queries