Well, I don't think that the data control would know anything about
lngValue. I never use bound controls like that, I just write raw SQL
statements when I have to do something like that so I don't know how you
would set a filter based on a specific non-constant value.
What version of Outlook are you using and what spreadsheet control and how
are you binding it to a data source and so on? I'll try to play with the
control and see if I can figure out how to do what you want.
Personally, I'd just use a grid control unbound to anything and use SQL in
my form code to get into the Access database using an ADO connection and
populate the grid that way. I know I can use any SQL statement possible that
way to filter my recordset and then iterate the recordset to populate the
grid control.

Signature
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
> I tried your suggestion, which gave me the following code in the custom
> form:
[quoted text clipped - 29 lines]
> Thanks for any further assistance!
> Mike
Mike Abrahamson - 23 Jul 2004 14:03 GMT
I am using Outlook 2003 with the Microsoft Office 11.0 Spreadsheet Control.
In the "Commands and Options" menu of the control, under the "Data Source"
tab, I am specifying the following connection string:
Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\server\data\AgencyWorks\AWproduction.mdb;Persist Security Info=True
Then in the "Command text or SQL" box I am using the following:
Select * FROM Total Query WHERE (([Total Query].FSTAGT) = lngValue)
I agree that it would probably be easier to just include the SQL statement
in the form's code. One of my concerns with any scenario is performance.
The external database I am referencing has several thousand records in the
specified query. I can't have users trying to open the custom contact form
and having to wait several seconds or minutes for the code to perform the
SQL query against the DB. I'd like to have the grid control on page 2 or 3
of the form and either cache the info or run in the background after the
form is opened so the user can at least see the info on the other pages of
the form. Is this a problem?
Thanks so much for your help thus far!
Mike
> Well, I don't think that the data control would know anything about
> lngValue. I never use bound controls like that, I just write raw SQL
[quoted text clipped - 48 lines]
> > Thanks for any further assistance!
> > Mike
Ken Slovak - [MVP - Outlook] - 23 Jul 2004 14:51 GMT
If what you want to do can be done at all then you'd somehow have to use a
fully qualified reference to the field in the Outlook item rather than to a
variable value. I don't think it can be done.
I haven't noticed any particularly long response times when accessing a
database using ADO and SQL from form code in VBScript. I do it all the time.
If you want things to be even faster you could use COM addin compiled code
to get the recordset and then fill in a grid control when the form opens by
handling the NewInspector event and if the item in the Inspector is one of
interest you can get the field value, get your filtered recordset and then
populate the grid. You might even be able to access the properties of the
spreadsheet control on the form and populate that control from the filtered
recordset that way.

Signature
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
> I am using Outlook 2003 with the Microsoft Office 11.0 Spreadsheet Control.
> In the "Commands and Options" menu of the control, under the "Data Source"
[quoted text clipped - 20 lines]
>
> Mike