View Single Post
  #8  
Old September 25th, 2006, 07:33 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Combo Box question

I don't know what you mean by the spacenum comb alread in use. Isn't this
the combo you use to show unassigned spaces from the table that has the space
numbers?

We can make it work. Tell me a little about your tables.
What fields are in the spacenum table?

Do you have a field in the spacenum table that tells whether the number is
assigned or not?

What field in the main parking table is used to store the assigned space
number?

Do you want the combo box to populate the spacenum field in the main parking
table when you choose a space?

Does it also need to update anything in the spacenum table?

Is the Comb Box a bound control?

If you can answer these questions, I can make some recommendations on how it
will work.

Also, there appears to be a syntax error in the query you posted.

(Select SpaceNum From [Main Parking Table] Where Assigned.[Main Parking
Table]= false);

The way it is written, it is looking for a field named [Main Parking Talbe]
in a tabled named Assigned.
"Fred" wrote:

A couple of problems with this, One my spacenum combo box is already in
use plus I have my space numbers in a different table. I cant get the
assigned check box to populate both tables. I am trying to use a query
like the following:

SELECT SpaceNum
FROM Spacenum
Where SpaceNum Not IN
(Select SpaceNum From [Main Parking Table] Where Assigned.[Main Parking
Table]= false);
This does not work Thanx for the help
Klatuu wrote:
Okay, great. That makes it really easy. Hopefully, you have a field in your
parking space table that tells whether or not it is assigned. If you don't,
you need one. For this, I would suggest a Boolean (yes/no) Field. For
example purposes, lets call it [SPACE_AVAILABLE] and True means it is not
assigned.

Make the Row Source for the combo a query filtered on that field:
SELECT [SPACE_ID] FROM tblParkingSpaces WHERE [SPACE_AVAILABLE]

This will cause only unassigned spaces to be presented in the combo.

What I would is write a Sub in the form module and call it from the After
Update events of the Combo Box and the Check Box.

Private Sub UpdateSpace()
Dim blnAssign As Boolean

blnAssign = Screen.ActiveControl.Name = "chkUnAssign"
Me.chkUnAssign = blnAssign
CurrentDb.Execute "UPDATE tblParkingSpaces SET [SPACE_AVAILABLE] = " &
blnAssign & ";", dbFailOnError
Me.cboSpaceAvailable.Requery
End Function.

Then in the After Update of the Combo Box and the Check Box:
Call UpdateSpace

"Fred" wrote:

I am assigning parking spaces and one is assigned I want that one to be
pulled from the drop down not from the field. When the person leaves I
unassign the parking spot and I need it to reappear in the drop down.
Thanx Fred
Klatuu wrote:
This number you assign - When you check the box to un assign the number, is
the number removed from the record or do you have a field in the record that
tells you whether the number is assigned?

If you un assign a number, then later deside to reassign a number to the
record at a later date, does in get a new number or is it reassigned the
original number?

"Fred" wrote:

Thanx Klatuu
I also need to know the code to remove the numbers and put the numbers
back in. Sorry for the confusion. Fred
Klatuu wrote:
You will need to requery the combo in two places.
1. In the After Update event of the control where you assign the number.
2. In the After Update event of the check box.

"Fred" wrote:

Hi Folks,
I have created a combo box full of numbers. I also have a check box
called assigned. When I create a record with a number that is assigned
I would it to be taken out of the combo box list and then when I
uncheck the box I would like it to reappear in the list. Where is the
best place to put my requery statement? Thanx for all your help Fred