Microsoft Access ----------- doubleclick on a field to change it's value


I am using a continuous form in Access 2010.

I have a database field [tag] which only accepts "Y" or "N".  It's the only field that I have not locked.    I can type in "Y" or "N" and that is fine,  but I would like to do this programically via double click.  Here is the code.

Private Sub Tag_DblClick(Cancel As Integer)
If Nz(Me.[Tag]) = "Y" Then
    [Tag] = ""
    [Tag] = "N"
End If
End Sub
Who is Participating?
danishaniConnect With a Mentor Commented:
Why don't you use a Boolean field yes/no?

If you persist, try this, replace Text22 into your Name "Tag":

Private Sub Text22_DblClick(Cancel As Integer)

If IsNull(Me.Text22) Or Me.Text22 = "" Then

Me.Text22 = "Y"

ElseIf Me.Text22 = "Y" Then

Me.Text22 = "N"

ElseIf Me.Text22 = "N" Then

Me.Text22 = "Y"

End If

End Sub

Open in new window

Hope this helps,
peispudAuthor Commented:
Nope...  That works fine on a regular textbox but does not work on the datafield in a continuous form.
peispudAuthor Commented:
I figured out that I have to create a recordset based on the primary key and update this field.

Thanks for your input though!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.