Problem with referencing control on On Current event of continuous form

C

Chris Strug

Hi,

I gather that this is quite a popular question however I'm completely unable
to find a solution through google. So if anyone can provide a helping hand
it would be greatly appreciated.

I have an Access 2003 ADP which contains a bound continuous form. Everything
(for once) is working just fine except:

Based on the contents of one control in the form I'd like to prevent the
user from editing that record depending on the contents. I.e. if txtStatus =
"Cancelled" then prevent changes to that record.

Now I understand that by using continuous forms all I should have to do is
to test the value of the txtStatus control in the current event and enable /
disable the "allowedits" property of the form as the current event will run
for every record that gets the focus.

However it won't let me get that far. Everytime I reference a control in the
continuous form in the Current event of the form, the event runs but I get
the error message:

"Run-time error '2424':

The expression you entered has a field, control, or property name that <app
name> can't find."

I'm at a loss. Can anyone explain what the application is doing and how I
can change it so that it will let me examine the status of the current
record and react accordingly. The form doesn't appear to be able to be able
to reference the txtStatus control.

The on current event contains the following code:

Private Sub Form_Current()
If Me!txtStatus = "Cancelled" Then
Me.AllowEdits = False
Me.AllowDeletions = False
Else
Me.AllowEdits = True
Me.AllowDeletions = True
End If
End Sub


Thanks

Chris.
 
R

Ron Weiner

Chris

If I had to guess I would guess that the control name is not txtStatus.
Look to see if you made a Typo somewhere. Also loose the Bang operator in
Me!txtStatus and replace it with a Dot. In fact why not leverage Access VBA
intellisense to help with this by typing Me.txt and looking to see what
Access offers as possible names of controls on your form might be.

Ron W
www.WorksRite.com
 

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