Run-time error 438

freeon

Registered User.
Local time
Today, 16:56
Joined
Oct 29, 2018
Messages
17
I'm new to access but have been getting by with excel VBA for the past year, but not a coding expert. I'm trying to create a folder on button press put can't seem to get it to work. I get Run-time error 438 Object Doesn't Support This Property or Method. If I replace Me.lblTitle with test it works ok. What am I doing wrong?

PHP:
MkDir  MkDir "P:\ Projects\Access" & Me.lblTitle
 
Well, if that was a cut/paste then a few problems jump at me.

1. MkDir appears twice in a line, which doesn't seem quite right.

2. You have a leading space in the path element "Projects" and it might not like that. I know you can have embedded spaces in file path elements, but I didn't think that leading spaces were allowed. (I could be wrong on that one.)

3. But even worse, we do not know details of Me.lblTitle, and what I fear is that if that really IS a label (based on the lbl prefix), Me.lblTitle will always fail. You see, IF that is a label then as a control it does not have a .Value property, but the syntax you used defaults to the .Value property. It might be that the control in question doesn't support the implied .Value property, which is well within the meaning of error 438.
 
This is the correct copy paste, so this should clarify item 1 and 2. As for item 3 I just added a text box to the form and access named it lblTitle


PHP:
MkDir "P:\Projects\Access" & lblTitle
 
what is the text of lblTitle? if it contains characters that are illegal in windows directories the code will fail, tho' not sure if it would generate this error or another one.

you say it works if you use 'test' - I presume you mean in replacement of lblTitle?. what I am suggesting is that your folder Projects needs to already exist and you are looking to create folders called something like 'AccessABC', 'AccessDEF' etc
 
The text in lblTitle is letters only. No illegal characters. I'm just trying to create a folder named after the text in the textbox. Project and access folder already exist. The final form will have more fields, I'm just trying to start with a simple form to get it working.
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    32.9 KB · Views: 120
Project and access folder already exist
that's not where you are trying to create a new folder

your code (once working) is creating a folder called 'AccessSomeProjectName' in a folder called projects

I just added a text box to the form and access named it lblTitle
that a new one on me, normally they are named after the field name it is bound to or if unbound then something like 'text1', 'text2'

I suspect you are not providing the full information for us to be able to help you
 
OMG :cool:. I was using "lblTitle" from Label Name instead of using Title from Name. Also there is \ after access(it's just not showing up in the post for some reason). So it creates the new folder named after the project to the access folder. Everything works now. Thanks for your replies. It made me look in the right places.
 
was using "lblTitle" from Label Name instead of using Title from Name
that is what Doc suggested in the first response
 
I just didn't get what he was saying.
for the future, better to clarify than ignore - could have spent many more posts trying to come up with other reasons for your error
 
freeon - just ask. I live with the idea that sometimes I shoot over people's heads but that was not my intention.

I'll explain this better, maybe.

I was using "lblTitle" from Label Name instead of using Title from Name.

What I was saying is that IF lblTitle is the name of a control that happens to be a label, using it that way would by default ask for the .Value property of that named control. But if it is a label, that property is not defined because labels have no value. And error code 438 tells that the property you tried to reference wasn't there. Since labels don't have values and the way you used Me.lblTitle asks for a value, that is why you got that particular error.

Is that clearer?
 

Users who are viewing this thread

Back
Top Bottom