showing/hiding buttons based on other form

  • Thread starter Thread starter Steven Van Impe
  • Start date Start date
S

Steven Van Impe

Hi,

I'm trying (in Access97) to make certain buttons appear/disappear when
opening a form, based on data in a hidden form with unbound fields.
The unbound field indicates the status ("", "add", "edit", "link"),
and based on this information I want to have a button either "Edit
record" (if the form is in the normal, browse-only state), "Lock
record" (if the form is in the edit state) or no button at all (in the
link state).

My code (below) doesn't seem to work properly. Both buttons are
"Visible = False" by default, yet they keep showing up. Switching from
"Edit" to "" seems to work, but having both disappear doesn't.

Thanks in advance!
Steven


Private Sub Form_Load()

If Forms![Hidden]![EditMode] = "Add" Then
Forms![Recordings]!Edit.Visible = False
Forms![Recordings]!Lock.Visible = False
End If
If Forms![Hidden]![EditMode] = "Edit" Then
Forms![Recordings]!Edit.Visible = False
Forms![Recordings]!Lock.Visible = True
End If
If Forms![Hidden]![EditMode] = "" Then
Forms![Recordings]!Edit.Visible = True
Forms![Recordings]!Lock.Visible = False
End If
If Forms![Hidden]![EditMode] = "Link" Then
Forms![Recordings]!Edit.Visible = False
Forms![Recordings]!Lock.Visible = False
End If

End Sub
 
Only a guess here, but the first thing I would try is to surround the Edit and
Lock with brackets. Since these are probably reserved words, I would guess at
some confusion on what is supposed to be referenced.

You might try a name change on the buttons (btnEdit and btnLock) and see if that
fixes the problem.
 
Back
Top