You don't need to reference the listbox directly.
Set the listbox up with a secondary datasource that does not populate
automatically. In you button handler use code something like the following:
Object qryAdaptObj;
ADOAdapter qryAdapt;
string sSQL = "SQL String based on current form data"
qryAdaptObj= thisXDocument.DataObjects["ListBoxsDatasource"].QueryAdapter;
qryAdapt= (ADOAdapter) qryAdaptObj;
qryAdapt.Command = sSQL;
thisXDocument.DataObjects["ListBoxsDatasource"].Query();
thisXDocument.View.ForceUpdate();
> I just started playing around with Infopath so I'm not sure this can be done,
> but here goes...
[quoted text clipped - 8 lines]
> put in some test message boxes above and below the action and those boxes do
> come up.
Joemanc - 07 Apr 2005 15:51 GMT
Thanks for the help. No luck yet, but I think I'm close. This is my code:
Public Sub CTRL64_OnClick(ByVal e As DocActionEvent)
Dim qryAdaptObj As Object
Dim qryAdapt As ADOAdapter
Dim sSQL As String
sSQL = "select client_name from f_client where client_name like 'A%'"
qryAdaptObj = thisXDocument.DataObjects("f_client").QueryAdapter
qryAdapt.Command = sSQL
thisXDocument.DataObjects("f_client").Query()
thisXDocument.View.ForceUpdate()
'f_client is my secondary datasource.
The listbox in the Infopath form is still not populating. It looks like it's
getting the data from the data source, just not adding to the listbox. The
listbox is bound to the secondary datasource: f_client:client_name field.
There is 1 line of code you gave me that I'm not sure what to do with:
qryAdapt= (ADOAdapter) qryAdaptObj;
> You don't need to reference the listbox directly.
>
[quoted text clipped - 31 lines]
> do
> > come up.
Joemanc - 07 Apr 2005 21:59 GMT
I got it. I had the drop-down box list box entries setting set to 'Enter list
box entries manually'. What's weird is I had to Re-create my data connection
to get the repeating entries to take the correct field.
> You don't need to reference the listbox directly.
>
[quoted text clipped - 31 lines]
> do
> > come up.
Reema Raj - 25 Apr 2005 10:36 GMT
how to do the same using C# ???