The current event of a continuous form is:
Private Sub Form_Current()
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End sub
This works fine. The form has a bound control QuoteNumber with its
control source as QuoteNumber. This is a text field.
However I wish to extend this and disable another button if the
QuoteNumber has a particular value:
Private Sub Form_Current()
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
If Me.QuoteNumber = "Regret" Then
Me.RegretButton.Enabled = false
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End if
End sub
As soon as I do this I get:
Run-time error 2424
The expression you entered has a field, control, property name that
Microsoft Access can't find.
So I simplified it to:
Private Sub Form_Current()
Debug.print Me.QuoteNumber
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End sub
but this gives the same error. In the working version at the top I can
step through with the debugger and see that Me.QuoteNumber has correct
values, either null or some text but as soon as I try to use the value
of the control/field in some other way things go pear shaped.
Why is it that when I try to do anything else with it, I get an error?
I have replaced the . by !, decompiled, compacted and even deleted the
form and imported a fresh copy from another database but to no avail.
I must have done something similar a thousand times without problem but
something odd seems to be happening here.
Any guesses would be welcome.
Jim