If...Then question

  • Thread starter Thread starter Kelvin
  • Start date Start date
K

Kelvin

I have a button with an on click event like this:

If Me.Comments = "" Then
Me.LockedRecord = False
Else
Me.LockedRecord = True
End If

But it's not doing what I want.

I want the button to set the value of the check box named "LockedRecord" to
be set to false if there is no data in the "Comments" field and true if the
"Comments" field has data.

What is the proper syntax for it to recognize that the Commnet field is
blank?

Thanks

Kelvin
 
hi Kelvin,
If Me.Comments = "" Then
Me.LockedRecord = False
Else
Me.LockedRecord = True
End If

I want the button to set the value of the check box named "LockedRecord" to
be set to false if there is no data in the "Comments" field and true if the
"Comments" field has data.
Try this:

Private Sub cmdMyButton_Click()

LockedRecords.Value = (Me![Comments] <> "")

End Sub

There is a difference between setting the value of the field behind the
form and the value of the control. To avoid this confusion you should
always name your controls, before referring to them.

So a proper name in your case:

chkLockedRecords.Value = (Me![Comments] <> "")


mfG
--> stefan <--
 
Me.LockedRecord = Len(Nz(Me.Comments, vbNullString)) > 0

--
Dave Hargis, Microsoft Access MVP


Stefan Hoffmann said:
hi Kelvin,
If Me.Comments = "" Then
Me.LockedRecord = False
Else
Me.LockedRecord = True
End If

I want the button to set the value of the check box named "LockedRecord" to
be set to false if there is no data in the "Comments" field and true if the
"Comments" field has data.
Try this:

Private Sub cmdMyButton_Click()

LockedRecords.Value = (Me![Comments] <> "")

End Sub

There is a difference between setting the value of the field behind the
form and the value of the control. To avoid this confusion you should
always name your controls, before referring to them.

So a proper name in your case:

chkLockedRecords.Value = (Me![Comments] <> "")


mfG
--> stefan <--
 
Back
Top