Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box

Status
Not open for further replies.

rhonda11

Technical User
Nov 4, 2002
96
US
I have a form for project look-up base on a combo box that if you select the project id, another form display selected project. Within this form, user can update the project at the subform, in this there a "completed" check boxe, which that this project is completed. My question is, if the project is select to be completed, is there a way to disable or delected from the combox box? There' over 200 projects, most of them are completed,however, it's still in the in the combo box for selection to be updat.

I don't want to delete the record, I wanted to be disable or off from the combo box (I don't want to see it)

Any ideas? Thanks in advance.
 
Set the recordsource for the combobox to a query like:

Select ProjectID from Projects where completed = false

Then, in the gotfocus event of the combobox, add a line of code to update the list, like:

me.comboboxName.requery

-Coco

[auto]
 
Your combobox should reflect only those projects not completed. So there should be a completed field on their records. On the combobox rowsource, there should be a sql statement something like this:

SELECT [tblUser].[UserID], [FirstName] AS DEPARTMENT FROM tblUser WHERE [complete] = FALSE ORDER BY [FirstName];

Then on your checkbox AfterUpdate event, you could put:
Me![comboboxName].Requery

Comboboxes are initially set when the form is opened. So you have to do a Requery to reinitialize them.

Neil
 
Open your form in design view.

Select the combo box, and display properties.

Under "Data", select "Row Source

I think this SQL is right (I'm not great at SQL, so if it doesn't work, there's probably a syntax error). Try pasting this in the Row Source Field. You'll also need to change the "Column Count" property to "2".

"SELECT DISTINCTROW YourTable.YourField, YourTable.YourCheckbox
FROM YourTable
WHERE (((YourTable.YourCheckBox)=0));


Obviously, change the names of your tables and fields to match the actual names. If you have trouble with the SQL, invoke the query builder (by hitting the "..." to the right of the Row Source line). Then you can set it up quite easily. Just put 0 in the criteria row.



 
Thanks guys, it works!! My combo box record source or row source already have a sql statement and all I did was add ...WHERE [projectcompleted]=False. I requery the combo box afterupdate.

Thank you all, you been very helpful, I appreciate you help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top