Re: filtering bound data based on custom field

From: Ken Slovak - [MVP - Outlook] (kenslovak_at_mvps.org)
Date: 07/13/04


Date: Tue, 13 Jul 2004 13:36:58 -0400

If you are querying a numeric field in a database you can't use a string
value for the SQL query. Cast your string value to a Long:
Dim lngValue
lngValue = Val(strAgencyWorksID)

then use that in your SQL string. Make sure the Long value is not enclosed
in quotes or it will end up as the name of the variable rather than its
value.

-- 
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Mike Abrahamson" <mike@bsmg.net> wrote in message
news:e$uTaWPaEHA.3804@TK2MSFTNGP10.phx.gbl...
> OK, so far I'm using this code in the custom form:
>
>     Dim strAgencyWorksID
>     Sub cmdLinkProduction
>
>         strAgencyWorksID = Item.UserProperties("Agency Works ID")
>
>     End Sub
>
> Then in my SQL statement on the Spread*** control I am specifying the
> following (I already have the ADO connection string defined elsewhere and
> can pull in data from the desired database query if I don't use the WHERE
> statement below):
>
>     Select * FROM Total Query WHERE ((([Total Query].FSTAGT) =
> strAgencyWorksID))
>
> All I get using this code in the spread*** control is "No value given
for
> one or more required parameters."  I've also tried specifying
> "strAgencyWorksID.Value" as the last argument but got the same result.
Full
> disclosure - the custom field in question is a Number field... would that
> make a difference?
>
> I'm really not a programmer so this is all Greek to me (well, I sort of
> understand some of it).  Can anyone tell me if I'm way off base here?  I'd
> appreciate any help.  I still can't help but think that what I want to do
> isn't all that difficult for someone who knows what they're doing, which
> obviously I don't.
>
> Thanks for ANY help,
> Mike