.NET code

J

Joemanc

I just started playing around with Infopath so I'm not sure this can be done,
but here goes...
I'm using the InfoPath Toolkit for .NET(VB). On my Infopath form, I have a
drop-down list box. I'd like to populate this listbox with names from a
secondary data source. I have placed some buttons on my form to be able to
filter the data. I have the code that handles the click event for the
buttons, but from within that click event code, I can't find the drop-down
list box in the object model in VB.NET/InfoPath.
Alternatively, I've tried to use the Rules within the button, but the the
rule will not load my drop-down box. It doesn't seem to fire, although I have
put in some test message boxes above and below the action and those boxes do
come up.
 
M

MarkBatPRC

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();
 
J

Joemanc

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;


MarkBatPRC said:
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();

Joemanc said:
I just started playing around with Infopath so I'm not sure this can be done,
but here goes...
I'm using the InfoPath Toolkit for .NET(VB). On my Infopath form, I have a
drop-down list box. I'd like to populate this listbox with names from a
secondary data source. I have placed some buttons on my form to be able to
filter the data. I have the code that handles the click event for the
buttons, but from within that click event code, I can't find the drop-down
list box in the object model in VB.NET/InfoPath.
Alternatively, I've tried to use the Rules within the button, but the the
rule will not load my drop-down box. It doesn't seem to fire, although I have
put in some test message boxes above and below the action and those boxes do
come up.
 
J

Joemanc

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.

MarkBatPRC said:
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();

Joemanc said:
I just started playing around with Infopath so I'm not sure this can be done,
but here goes...
I'm using the InfoPath Toolkit for .NET(VB). On my Infopath form, I have a
drop-down list box. I'd like to populate this listbox with names from a
secondary data source. I have placed some buttons on my form to be able to
filter the data. I have the code that handles the click event for the
buttons, but from within that click event code, I can't find the drop-down
list box in the object model in VB.NET/InfoPath.
Alternatively, I've tried to use the Rules within the button, but the the
rule will not load my drop-down box. It doesn't seem to fire, although I have
put in some test message boxes above and below the action and those boxes do
come up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top