开发者

Parameter Query

开发者 https://www.devze.com 2023-02-05 19:10 出处:网络
I am doing a small hotel reservation database. Upon guests checking in, they are given a Parking Lot Access card (that is numbered) and will need to return it at che开发者_JS百科ckout to avoid being c

I am doing a small hotel reservation database. Upon guests checking in, they are given a Parking Lot Access card (that is numbered) and will need to return it at che开发者_JS百科ckout to avoid being charged an extra fee. The below query lets the user enter the Parking Lot Access card Number.

SELECT AccessKey.AccessKeyID, AccessKey.Distributed
FROM AccessKey
WHERE (((AccessKey.Distributed)=false));

On my form is a combo box that has the list of card numbers. I need help on coding the combo box to only show the card numbers that are available, when checking in a new guest.

For example... guest one checks in and gets card #3, for the next guess, the combo box will not show card #3 bc it has been distributed.

Then I have created a check box to mark if the card was returned at the end of the guests stay. Once this box is checked the card number goes back into the combo box.


Some things are not very clear, like when is the choice of accesskey definite. Is it when selected in the combobox, or is there a button on the form that saves all data on the form?

Anyway, the query you have created yourself is a good start. If you create a combobox, you can add this query to the combobox's rowsource. The accesskey.distributed in the query is not really needed however, since you will only select those with value 'false' anyway. Make sure the bound column of this combobox is set to 1, since that is the key number you are using.

Now in the event which will save the state of the accesskey.distributed (whether it is a button onclick event or the combobox afterupdate event) , you can write some code as follows:

CurrentDb.Execute "UPDATE AccessKey SET AccessKey.Distributed = true WHERE AccessKey.AccessKeyID = " & Me.ComboBoxName.Value
  Me.ComboBoxName.Requery

This last line will make sure the combobox updates and the selected key will not be visible in the list anymore.

Now for your second part of your question, it is a lot more unclear. That checkbox, is it on the same form, or a form about the customer checkout with data related to this customer (such as his keynumber). Any way, pls clarify this second part of you question a bit more.

0

精彩评论

暂无评论...
验证码 换一张
取 消