MS Access d/b saved parameter query problem

MS Access d/b saved parameter query problem

Post by Larry Reko » Thu, 05 Aug 2004 03:27:12


Trying to convert a page that adds records to a table. Have
successfully done it (to a point) using the "saved parameter query".

At first it didn't work, kept getting a "page not found" when
submitting the new data, so i went back and started revising the query
and the asp page to add one parameter at a time.

It appears that as soon as I add a field that is a number field, I get
the "page not found" error.

does one have to do something different with number fields? It worked
fine before when I used the Execute method.

Thanks.

Larry Rekow
- - - - - - - - - - - - - - - - - -
"Forget it, Jake. It's Chinatown."
 
 
 

MS Access d/b saved parameter query problem

Post by Larry Reko » Thu, 05 Aug 2004 03:53:23

After further testing, I think I have a clue to the problem.

I put some logic into this variable so that it would say "null" if it
were 0

in otherwords, the variable I setup looks like:

strkilos = Request.Form("kilos")
if strkilos = "" then
strkilos = " Null "
else
strkilos = "#" & strkilos & "#"
end if

but using the "saved parameter query", I get an error if the field is
empty. Will this work if I change the "if" statement somehow??

Thanks,

Larry Rekow
- - - - - - - - - - - - - - - - - -
"Forget it, Jake. It's Chinatown."

 
 
 

MS Access d/b saved parameter query problem

Post by Bob Barrow » Thu, 05 Aug 2004 04:20:41


Can't say without seeing the code that actually calls the query. Some
details about the table structure wouldn't hurt either (relevant field names
and datatypes).

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
 
 

MS Access d/b saved parameter query problem

Post by Larry Reko » Thu, 05 Aug 2004 04:38:48

On Tue, 3 Aug 2004 15:20:41 -0400, "Bob Barrows [MVP]"



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Thanks Bob. I was able to correct the problem by changing the way i
created the variable to simply:

strkilos = Request.Form("kilos")
if strkilos = "" then
strkilos = Null
end if

In otherwords, I just had to remove the quotation marks from around
the word Null, and it works both when there is a number in the field
and when there is not.

Below is the way I'm calling the query, and I still think it may not
be the most elegant, but here goes:

Set objHamDB=Server.CreateObject("ADODB.Connection")
objHamDB.ConnectionTimeout=60
objHamDB.Open import_entry
Set recordSet=Server.CreateObject("ADODB.Recordset")
recordSet.Open "SELECT (max(reference)+1) as MyMax FROM AIRFREIGHT",
objHamDB
newnum=recordSet("MyMax")
recordSet.Close
Set recordSet=Nothing
objHamDB.qAAR strawb, strshipper, strconsignee, strpcs, strkilos,
strcommodity, strdest, stretd, streta, strlast_flight, strremarques,
strcustoms, strarrived, strbilled, newnum, pnow, struser
objHamDB.Close
Set objHamDB=Nothing

For reasons I needn't go into, I can't use the autonumber feature for
my file numbers, so I briefly create a recordset to obtain the highest
number, then add one and create the variable "newnum"

Perhaps you can advise a better way to do this, tho the above is
working for me now ok.

Thanks again. I've been going thru this application I created some
time ago and I'm trying to convert things over to the "saved parameter
method" to make it more efficient, and to get more familiar and
comfortable using this method.

Larry Rekow
- - - - - - - - - - - - - - - - - -
"Forget it, Jake. It's Chinatown."