Matt H
Matt H

Reputation: 147

MS-Access Check box IF statements

How would i add a check("chk3") that will be ticked when ("Customer order Number") field has been inputted. when an order number is entered, then the check box will tick..

i also would like to know if it is possible that When the value field ("Value") is under £10,000 then the check box ("chk2") will tick. if it is over £10,000 then it will not tick

enter image description here

Upvotes: 1

Views: 4268

Answers (3)

Santosh
Santosh

Reputation: 12353

You may use AfterUpdate events for such validations.

Nz function checks for null value and converts them to empty string & 0 respectively

For Customer Order Number:

Private Sub txtCustomerOrderNo_AfterUpdate()
    If Nz(Me.txtCustomerOrderNo, "") <> "" Then
        Me.chk3 = True
    Else
        Me.chk3 = False
    End If
End Sub

For Project value is less than 10K:

Private Sub txtProjEstimate_AfterUpdate(Cancel As Integer)
    If Nz(Me.txtProjEstimate, 0) < 10000 Then
        Me.chk2 = True
    Else
        Me.chk2 = False
    End If
End Sub

Upvotes: 3

ccarpenter32
ccarpenter32

Reputation: 1077

It sort of depends what you're trying to do with the chk3 validation. If you're looking for a specific structure. For instance, a 10 digit number, then you would want a validation along those lines within the IF Statement. Something like:

(Using AfterUpdate)

If Me.[Customer order Number] LIKE "##########" Then
    Me.chk3 = True
End If

Similiarly with the validation on the ck2 > £10,000 (assuming this is an appropriately designated currency field):

If Me.[Value] <= 10000 Then
    Me.chk2 = True
End If

Upvotes: 1

Johnny Bones
Johnny Bones

Reputation: 8402

Depends on your version of Access. In older versions, it was the AfterUpdate event. In newer ones, I think it's OnExit.

In whichever event of Customer Order Number, just set its value to True.

Private Sub CustomerOrderNumber_Exit(Cancel As Integer)
  Me.chk3 = true
End Sub

Upvotes: 2

Related Questions