Button Enabled on true/false

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

Guest

I have a button that will open another form on one of my forms. I have set
this buttons Enabled property to no. On AfterUpdate on a Check box I have
set the buttons enabled property to true.

Private Sub CarrierClaim_AfterUpdate()
cmdCarrier.Enabled = CarrierClaim
End Sub

That is working fine, but if I go to another record where CarrierClaim is
False (that is unchecked) cmdCarrier is still enabled. I need the button to
enabled and disable depending on the value of the CarrierClaim control.

Also - I would like it if when the button is clicked, a date is entered into
another control on the original form. In English, when cmdCarrier clicked,
enter current date into ProgressDate control.

Thanks.
 
Use the Current event of the form to set the Enabled state of your button.

Include error handling, in case the button has focus when you move record.

You can assign the date to the other control by adding this line to the
AfterUpdate of the check box:
Me.ProgressDate = Date()
or, if you wanted the time as well as the date:
Me.ProgressDate = Now()

BTW, in earlier versions of Access (e.g. 97), that code could open a
reference that Access did not release, so the database could not be closed
except through Ctrl+Alt+Del. Referring to the Value property explicitly
stoped that. It is also possible to have a Null value in a check box (e.g.
at a new record, so I suggest you use:
Me.cmdCarrier.Enabled = Nz(Me.CarrierClaim.Value, False)
 
I can see you have posted Allen, but I can't read anything. the box on the
right is empty.
 
That the post From Allen, I hope you can see

Use the Current event of the form to set the Enabled state of your button.

Include error handling, in case the button has focus when you move record.

You can assign the date to the other control by adding this line to the
AfterUpdate of the check box:
Me.ProgressDate = Date()
or, if you wanted the time as well as the date:
Me.ProgressDate = Now()

BTW, in earlier versions of Access (e.g. 97), that code could open a
reference that Access did not release, so the database could not be closed
except through Ctrl+Alt+Del. Referring to the Value property explicitly
stoped that. It is also possible to have a Null value in a check box (e.g.
at a new record, so I suggest you use:
Me.cmdCarrier.Enabled = Nz(Me.CarrierClaim.Value, False)
 
Thanks Allen (and Ofer)

Is there some way I can assign the Me.ProgressDate = Date () to the OnClick
event of the button as well as opening the next form? This would prove more
efficient than after updating the check box as not all records will have the
check box updated.

Cheers
 
You could execute an Update query to bring all the affected records into
synchronization, but that does not sound like a good idea to me. There must
be some way to create a normalized design where there is only one value in
one location to keep up to date.
 
Yes you can
On the Onclick event of the button, you can write the code

Me.ProgressDate = Date ()
Docmd.OpenForm "FormName"
 
Thanks very much, all done!

Cheers

Ofer said:
Yes you can
On the Onclick event of the button, you can write the code

Me.ProgressDate = Date ()
Docmd.OpenForm "FormName"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top