Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why am I getting this compile error.... 1

Status
Not open for further replies.

AccessGuruCarl

Programmer
Jul 3, 2004
471
US
Dim p As Property
Dim db As DAO.Database

Set db = CurrentDb()
'set the required expiry date (defaults to 30 days from now)

On Error Resume Next
With db
'check to see if already defined
Set p = .Properties("myCompany")
If Err = 3270 Then
Set p = .CreateProperty()
p.Name = "myCompany"
p.Type = dbText
p.Value = 0
.Properties.Append p
Err.Clear
Else
p.Value = sCoName
End If

Error is:
Compile Error
Can't assign to read-only property.

I have used this method in the past with no problems...

Thanks...

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
It doesn't quite work like that, you need:

[tt]dbs.CreateProperty("MyCompany",dbText, "YooHoo")[/tt]

Here is a function (Microsoft, I think):

Code:
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    Dim dbs As Object, prp As Variant
    Const conPropNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo Change_Err
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True

Change_Bye:
    Exit Function

Change_Err:
    If Err = conPropNotFoundError Then    ' Property not found.
        Set prp = dbs.CreateProperty(strPropName, _
            varPropType, varPropValue)
        dbs.Properties.Append prp
        Resume Next
    Else
        ' Unknown error.
        ChangeProperty = False
        Resume Change_Bye
    End If
End Function
 
Thanks Remou,

I'm very familiar with that function...

I'm surprised I didn't notice the formatting!

That's what I get for trying to take a shortcut and pasting unfamiliar code, instead of looking for code I've already created. It was late...


Here's a star...

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Remou,

Not sure how to remove that post regard...
Need help looping a txt file to save as it as seperate txt files.
thread181-1372701

I wasn't aware IE did that

Can you request that it be deleted!

I'll repost it later today, so it no so wide.

Your on track with what I was looking for, but somewhere on this site there is a function that remembers the last position read, the you begin reading at this point +1 when you grab the next section of text.

I did put something together with the FileSystemObject, it's not to pretty... But it's working....

I'll do a little more searching before I repost.

Thanks...

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Can you request that it be deleted
Simply Red Flag it!
 
PHV---

How do I do that PHV?

Never tried red flagging a post.


AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
You simply click in the middle bottom of your post the following text:
Inappropriate post?
If so, Red Flag it!
In the popup windows you explain why you want the thread to be deleted/edited.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the info....

I can see it now...

That post was to wide for me to see that.

Thanks again...

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top