Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic CommandButton based on field value...

Status
Not open for further replies.

hoialmen

MIS
Dec 10, 2001
53
US
Hi All!

I have a subForm that lists .pdf files that are attached to the parent record in the main form. Next to each .pdf record in the subForm, there is a CommandButton that is either used to attach a new .pdf (new record) or remove an existing .pdf. What I would like to do is have the subForm loop through all the records and change the Caption for the CommandButton to "Remove" if it is associated with an existing record or "Attach" if it is associated with a new record. The way I am trying to do it now is with the following:

Private Sub Form_Current()

If Not IsNull(Me.file_path) Then
Me.cmdLinkFile.Caption = "Remove"
Me.cmdLinkFile.ForeColor = 255
Me.cmdLinkFile.ControlTipText = "Remove file from this record."
Else:
Me.cmdLinkFile.Caption = "Attach"
Me.cmdLinkFile.ForeColor = 0
Me.cmdLinkFile.ControlTipText = "Link file to this contract."
End If

End Sub

The problem I'm having with this is that if the record has at least 1 .pdf associated with it, it changes the caption on all of the CommandButtons (including the new record) to "Remove" and changes the caption on the new record CommandButton to "Attach" only if there are no .pdf files associated with the master record.

Has anybody done anything like this before? And, if so, could you share your thoughts with me.

Thanks in advance!



Nathan C. Hoialmen
President
Encephalon Business Solutions, LLC
 
Yes, I've had this problem and never found a workaround. The only thing I can think of is just to put a caption on it that says "Remove/Attach" and then when the user clicks it, have a msgbox confirming they are either attaching or removing for that record.

Unfortunately thats what the subform does, whatever the current record is, it sets it for all. Each row is not considered it's own entity, simply the same design with different record values.

Sorry I couldn't be of more help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top