Need help making an IF sentence in a form

Inkognito

Registered User.
Local time
Today, 12:47
Joined
Apr 4, 2008
Messages
43
Hi

I am making a database for several boat companies in Norway.
One of the forms is a form to fill out which boats are going to be hauled out of water for the winter, on which dates and which hours.

On a full day the companies can lift in total 21 boats of water.

So i have made the form so that there are 21 droplists, where they can select the member-number of the customer they want to register for the lift, and then all the information about the member automatically appears in the fields to the right of the droplist, including a field that says S or M, whether it is a Sailboat or a Motorboat.

The problem is that the companies can only handle 1 sailboat every hour, and in addition 2 motor boats (or just 3 motorboats).

So i really need to make a function that can check if more than 2 customers with sailboat are registered in the same hour. Preferably one would get a messagebox saying something if you tried to add a second customer with a sailboat on the same hour.

I am no good with visual basic, but im guessing that i need some kind of IF statement saying;
IF number1.boattype = S AND number2.boattype = S THEN something
elseif number2.boattype = S AND number3.boattype = S THEN something
elseif number1.boattype = S AND number3.boattype =S THEN something

I have been crawling the net to find an answer, but it isnt that easy to find, as i don't know excactly what to search for.
Could anyone please help me with this?
 
Solved

The problem is solved.

If interested, the solution was to add an AfterUpdate event to the dropdown list, use VB code, and enter this:

Private Sub Medlemsnr_AfterUpdate()
If Me.opplagsliste_BÅT = "S" Then
If Me.Opplagsliste_2_BÅT = "S" Then
MsgBox ("Sorry, only 1 sailboat per hour allowed")
Me.Medlemsnr = 0
ElseIf Me.Opplagsliste_3_BÅT = "S" Then
MsgBox ("Sorry, only 1 sailboat per hour allowed")
Me.Medlemsnr = 0
End If
End If
End Sub

The code had to be entered for all 21 dropdown's of course, and then set to check the 2 other dropdown lists for "S" in the same hour.
 

Users who are viewing this thread

Back
Top Bottom