rea newbee question on "object doesnt support this...."

splreece

Registered User.
Local time
Today, 14:17
Joined
Jun 2, 2016
Messages
40
Hi all I have the following code

Private Sub Command93_Click()
If Not Me.NewRecord Then
'Lock YourControl for each record.
Me!mem_RequestDetails.Locked = True
Else
Me!mem_RequestDetails.Locked = False
End If
End Sub


it should work as far as I can see as the "RequestDetails" field and the execution button are on the same form.

Can anyone see anything that would stop this from functioning (I wanted it to be button executed as the button is linked to some email vba through a call function).
 
Two questions:

When you click Command93, what is the exact error you receive

and...

When you chose Debug, which line is highlighted?
 
I tried this code with a textbox named mem_RequestDetails and it works fine. It locks the textbox when I click the button if the form is not on a new record. What problem are you having?
 
Two questions:

When you click Command93, what is the exact error you receive

and...

When you chose Debug, which line is highlighted?

Hi there,

Thanks

"The error is runtime error '438':

Object doesn't support the property or method."

Then on debug is highlights

" Me!mem_RequestDetails.Locked = True"


I've ensured the mem_RequestDetails is selected via the ctrl&spacebar method incase of spelling.

I have also put it in a sub of its own under a button that only does the sub (incase of code incompatibility).

I've also shut down and restarted incase for some reason it helps......it didn't..... ahh must be getting late in the day.
 
Well your syntax is correct, as Steve has already verified (it works on his test). Which leads me to believe you may have some sort of circular reference issue going on that the Access Gnomes (stolen from Missinglinq) does not like.

Try this:

Me!mem_RequestDetails.Controls.Locked = True

It cant hurt...
 
If it's on the form the code is called from shouldn't it be Me. not Me!

Me.mem_RequestDetails.Locked = True

What is mem_RequestDetails ? A text box. if so, is it called the same as the field that is the control source ? Rename it to txtRequestDet so you know you are referring to the control and not the field.
 
Hi minty



mem_RequestDetails is a memo (text box)



essentially the user keys in some details for a task and on pressing submit, I need a way to close the field (so no amendments) and then the rest of the vba is complete and functioning fine (separate sub).


if I use me. it states "data member not found" then debug points to" .Locked ="
 
Then I think my second guess is correct, about you trying to manipulate the data not the control. Change the name of the txtbox, then use that instead.
 
You can see that this code works with the field and textbox the same in the attached database. Maybe your form is corrupt. Try a compact and repair.
 

Attachments

doh.... thanks for your help everyone... it was simply the field and text box name were the same (I normally do that so I know what refers to what).. maybe going forward I get into the habit of the dbase field ref and the userform box ref have different conventions.
 
maybe going forward I get into the habit of the dbase field ref and the userform box ref have different conventions.

This is a life and massive time saver - a naming convention. txtMyFieldName cmbMyFieldName etc. etc. The field name is still there for ease of programming blindness, but so is the type of control.

Glad you sorted it.
 

Users who are viewing this thread

Back
Top Bottom