Code for Combo Box

Knoxville

Registered User.
Local time
Today, 16:09
Joined
Apr 30, 2002
Messages
16
My database requires me to keep a record of items that have become damaged. To do this I have made a form that allows me to select an item from a combo box(based on a query). After selecting the item from the combo box I then enter the item as being damaged by the use of a lookup wizard(wizard has Availible, Damaged, Borrowed) under the label of Status.
However this could lead to problems as after selecting the item I might forget to set its status to Damaged.
Is there a code I can put in the combo box(if so were do I put it?) that will change the Status to Damaged when I select an item from it? Also is there a code I can put in(also were does this go?) that insists that when an item is entered as Damaged the date it was damaged must also be entered?
Thanks!
 
I'm not sure what you mean by lookup wizard. If you are saying that you have a combo box that allows you to select an item and then takes you to that item's record in the form, I think it will work if you include something like the following in the after update event of the same combo box (after the code that takes you to the correct record)

'Mark item as damaged
ItemStatus = "Damaged"
'Move the focus to the Damaged Date field
DamagedDate.SetFocus

Now you are left with the focus in the DamagedDate field. Write the following code in the Lost focus event of the DamagedDate:

If isnull(DamagedDate) Then
msgbox "You must enter the date this item was damaged."
End If

Depending on how annoying you want to be, you could also have the above code move the focus back to DamagedDate. Then the code would automatically run again if the user tried to ignore your message box.
 

Users who are viewing this thread

Back
Top Bottom