Problem with Disabling a Cmd Button Based on Another field in the

N

nytwodees

I am using Access 2000.

I have a command button that should be enabled if the OwnerStatus = "Current
Owner" and disabled for any other value.

This is my code:

Function SetOneInvoiceCommand() As Boolean
Dim blnEnable As Boolean

If Me![OwnerStatus] = "Current Owner" Then
OneInvoiceCommand.Enabled = True
Else
OneInvoiceCommand.Enabled = False
End If

End Function

When I 1st enter the form, the OneInvoiceCommand button is ENABLED no matter
what the value is in the OwnerStatus field. However once I click the Owner
Status field once, the code works properly thereafter. Why is the code not
working immediately?

Note: ON Enter (for Owner Status) =SetOneInvoiceCommand()
 
D

Dorian

Code only runs when you tell it to run (by calling it) or if it is placed in
an event that gets triggered.
You probably also need to call the code from the Form Load event.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
N

nytwodees

Thanks Dorian for your speedy reply.

There is no "On form Load" either in the events for the OwnerStatus field or
the the Current Form. There is "On Load" for the Current Form.
I entered ON Load =SetOneInvoiceCommand(). I get the same results as
before. There must be another way!

Dorian said:
Code only runs when you tell it to run (by calling it) or if it is placed in
an event that gets triggered.
You probably also need to call the code from the Form Load event.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


nytwodees said:
I am using Access 2000.

I have a command button that should be enabled if the OwnerStatus = "Current
Owner" and disabled for any other value.

This is my code:

Function SetOneInvoiceCommand() As Boolean
Dim blnEnable As Boolean

If Me![OwnerStatus] = "Current Owner" Then
OneInvoiceCommand.Enabled = True
Else
OneInvoiceCommand.Enabled = False
End If

End Function

When I 1st enter the form, the OneInvoiceCommand button is ENABLED no matter
what the value is in the OwnerStatus field. However once I click the Owner
Status field once, the code works properly thereafter. Why is the code not
working immediately?

Note: ON Enter (for Owner Status) =SetOneInvoiceCommand()
 
N

NuBie via AccessMonster.com

Try This!

Private Sub Form_Current()

If Me![OwnerStatus] = "Current Owner" Then
OneInvoiceCommand.Enabled = True
Else
OneInvoiceCommand.Enabled = False
End If
End Sub


Thanks Dorian for your speedy reply.

There is no "On form Load" either in the events for the OwnerStatus field or
the the Current Form. There is "On Load" for the Current Form.
I entered ON Load =SetOneInvoiceCommand(). I get the same results as
before. There must be another way!
Code only runs when you tell it to run (by calling it) or if it is placed in
an event that gets triggered.
[quoted text clipped - 27 lines]
 
N

nytwodees

Hi Nubie:

Works perfectly!

Thanks a lot for your help.




NuBie via AccessMonster.com said:
Try This!

Private Sub Form_Current()

If Me![OwnerStatus] = "Current Owner" Then
OneInvoiceCommand.Enabled = True
Else
OneInvoiceCommand.Enabled = False
End If
End Sub


Thanks Dorian for your speedy reply.

There is no "On form Load" either in the events for the OwnerStatus field or
the the Current Form. There is "On Load" for the Current Form.
I entered ON Load =SetOneInvoiceCommand(). I get the same results as
before. There must be another way!
Code only runs when you tell it to run (by calling it) or if it is placed in
an event that gets triggered.
[quoted text clipped - 27 lines]
Note: ON Enter (for Owner Status) =SetOneInvoiceCommand()
 

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

Top