Form OpenArgs and ComboBox

K

keVin

How can I limit the contents of a Combo Box where one of the ComboBox fields
is equal to the OpenArgs of the form?

Thanks in advance!

K
 
F

fredg

How can I limit the contents of a Combo Box where one of the ComboBox fields
is equal to the OpenArgs of the form?

Thanks in advance!

K

Let's assume you are sending a [City] OpenArgts value to a form and
your combo box is to show only customers in that city.

Leave the Combo Box Rowsource blank.

Code the Form's Load event:
If Not IsNull(Me.OpenArgs) Then
Me![ComboName].Rowsource = "Select YourTable.CustName From YourTable
Where YourTable.City = """ & Me.OpenArgs & """"
Else
Me![ComboName].Rowsource = "Select YourTable.CustName, YourTable.City
From YourTable;"
End If

You'll show only customers from the City passed in the OpenArgs, or
both Customers and City if no OpenArgs has been passed.
 
K

keVin

Thank you, works like a champ!


fredg said:
How can I limit the contents of a Combo Box where one of the ComboBox
fields
is equal to the OpenArgs of the form?

Thanks in advance!

K

Let's assume you are sending a [City] OpenArgts value to a form and
your combo box is to show only customers in that city.

Leave the Combo Box Rowsource blank.

Code the Form's Load event:
If Not IsNull(Me.OpenArgs) Then
Me![ComboName].Rowsource = "Select YourTable.CustName From YourTable
Where YourTable.City = """ & Me.OpenArgs & """"
Else
Me![ComboName].Rowsource = "Select YourTable.CustName, YourTable.City
From YourTable;"
End If

You'll show only customers from the City passed in the OpenArgs, or
both Customers and City if no OpenArgs has been passed.
 

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

Similar Threads

Combo box 0
Form with Tab Control and OpenArgs 7
Combobox 1
Use of OpenArgs 5
Go to ItemID in listbox? 1
OpenArgs yawn yawn 9
Form Corruption 2
How can I refresh my table data? 3

Top