Note that there are some explanatory texts on larger screens.

plurals
  1. POUse form to check whether someone is older than given age
    text
    copied!<p>I've tried this code in order to get my form to tell me whether a customer is older than 16 or 18 if they're trying to hire a R16 or R18 movie.</p> <p>HireMovieID and HireCustomerID are two text boxes on my form. MovieID and CustomerID are columns within my MovieList and CustomerInfo tables. </p> <pre><code> Private Sub HireCommand_Click() If Not IsNumeric(HireMovieID) Or Not IsNumeric(HireCustomerID) Then MsgBox "Error: Not a number" Exit Sub End If Dim MovieRating As String Dim CustomerDOB As Date Dim Age16Check As Date Dim Age18Check As Date MovieRating = DLookup("[Rating]", "MovieList", "MovieID = [Forms]![HireForm]![HireMovieID]") CustomerDOB = DLookup("[DOB]", "CustomerInfo", "CustomerID = [Forms]![HireForm]![HireCustomerID]") Age16Check = DateSerial(-16, Month(Date), Day(Date)) Age18Check = DateSerial(-18, Month(Date), Day(Date)) If MovieRating = "R16" Then If CustomerDOB &gt; Age16Check Then MsgBox "This customer is too young to hire this movie" Else: MsgBox "This customer is old enough to hire this movie" End If ElseIf MovieRating = "R18" Then If CustomerDOB &gt; Age18Check Then MsgBox "This customer is too young to hire this movie" Else: MsgBox "This customer is old enough to hire this movie" End If Else: MsgBox "This movie does not have a restricted rating, thus this customer may hire this DVD" End If End Sub </code></pre> <p><strong>EDIT:</strong> When I run this code, if I have an R16 movie selected, it will say that all the customers are too young to hire it? How can I fix this?</p> <p>Thanks in advance for your help! :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload