|
When
you try to compare something, you need to compare like data types. This
may be why your database is never finding that date in there already. Try
something like this:
SELECT count(dateofpayment) AS rownum
FROM table
WHERE dateofpayment = #CreateODBCDate(form.dateofpayment)#
Furthermore, if you have a variables.rownum defined for
whatever reason, I believe CF will use that first, so don't do
this:
<cfif rownum gte
1> <!---(which could be
equivalent to variables.rownum)--->
Do
this:
<cfif myquery.rownum GTE 1>
And in
fact because Count() guarantees to return an integer >= 0, to be more
efficient do this:
<cfif myquery.rownum>
<!--- 1 or more records found, so
date already exists --->
Terry Fielder Network Engineer Great Gulf Homes / Ashton
Woods Homes [EMAIL PROTECTED]
Hello All,
I am having a little trouble checking for an
existing date. I have a form that passes a date from calendar that I am
using. The calendar outputs the date as follows 6/13/2002.
So I have a few fields that I insert into the
database along with that date.
There can only be one record per day. I try
to do a row count in the database before my insert statement to check if there
is a row with that date value but I keep getting 0
The field that is passed from the form is
dateofpayment and the field in the Access database is also
dateofpayment
So I do
select count(dateofpayment)
as rownum form table where dateofpayment =
#form.dateofpayment#
I have manually entered the data in the table so
there is already that date it should give me a record count of greater than
one.
So I attempt to do a
<cfif rownum gte 1>
Go back to change the date
</cfif>
But this is not working. Does anyone have a
better way to see if the date already exists with Access or can tell where my
logic is flawed?
Thanks in Advance
Mike
|