Refreshing Command buttons

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form called icb, it has a command button that opens another form
called renewal.

The buttons caption should be in red, when you click on it it opens renewal
that will update some details on the form icb. When you close renewal it
updates the data on icb automaticaly but I want the caption on the button to
go back to black.

I have tried doing this with requery but it losses the record you are
working on. Is there a way to just refresh or requery the button and its
forecolor?

Many thanks

James
 
hi,
I did something similar once but not with the opening and
closing of another form. as i think, i can not foster a
way.
here is the code i use to change the color on my button.
perhaps it will give ideas
If Me.cmdDisableEmpView.Caption = "Disable TL View" Then
Me.cmdDisableEmpView.Caption = "Enable TL View"
Me.cmdDisableEmpView.ForeColor = 65280
Else
If Me.cmdDisableEmpView.Caption = "Enable TL View" Then
Me.cmdDisableEmpView.Caption = "Disable TL View"
Me.cmdDisableEmpView.ForeColor = 255
End If
End If
 
James said:
I have a form called icb, it has a command button that opens another form
called renewal.

The buttons caption should be in red, when you click on it it opens renewal
that will update some details on the form icb. When you close renewal it
updates the data on icb automaticaly but I want the caption on the button to
go back to black.

I have tried doing this with requery but it losses the record you are
working on. Is there a way to just refresh or requery the button and its
forecolor?

Many thanks

James


I'm not sure how to requery the properties of a button to do what you want,
but in the "On Close" event of renewal you could put something like this:

If fIsLoaded("icb") Then ' check to see if the form is open
Form_icb.ButtonName.ForeColor = 0 ' set its caption color to black
End If

you can get the function fIsLoaded here:
http://www.mvps.org/access/forms/frm0002.htm

Alternatively, in the same event you could capture the record being worked
on, close the form, open it , then move to the record:
Dim strCriteria As String
If fIsLoaded("icb") Then ' check to see if the form is open
strCriteria = "[KeyFieldName] " = " & Form_icb.KeyFieldName
DoCmd.Close acForm, "icb"
DoCmd.OpenForm "icb"
Form_icb.RecordsetClone.FindFirst strCriteria
If Not Form_icb.RecordsetClone.NoMatch Then
Form_icb.Bookmark = Form_icb.RecordsetClone.Bookmark
End If
End If


Jack
 
Many thanks thats a great help.

Treebeard said:
James said:
I have a form called icb, it has a command button that opens another form
called renewal.

The buttons caption should be in red, when you click on it it opens renewal
that will update some details on the form icb. When you close renewal it
updates the data on icb automaticaly but I want the caption on the button to
go back to black.

I have tried doing this with requery but it losses the record you are
working on. Is there a way to just refresh or requery the button and its
forecolor?

Many thanks

James


I'm not sure how to requery the properties of a button to do what you want,
but in the "On Close" event of renewal you could put something like this:

If fIsLoaded("icb") Then ' check to see if the form is open
Form_icb.ButtonName.ForeColor = 0 ' set its caption color to black
End If

you can get the function fIsLoaded here:
http://www.mvps.org/access/forms/frm0002.htm

Alternatively, in the same event you could capture the record being worked
on, close the form, open it , then move to the record:
Dim strCriteria As String
If fIsLoaded("icb") Then ' check to see if the form is open
strCriteria = "[KeyFieldName] " = " & Form_icb.KeyFieldName
DoCmd.Close acForm, "icb"
DoCmd.OpenForm "icb"
Form_icb.RecordsetClone.FindFirst strCriteria
If Not Form_icb.RecordsetClone.NoMatch Then
Form_icb.Bookmark = Form_icb.RecordsetClone.Bookmark
End If
End If


Jack
 
Back
Top