A question on retriving DB properties

  • Thread starter Thread starter Alp Bekisoglu
  • Start date Start date
A

Alp Bekisoglu

Hi Experts,

I have the following code that refuses to work.
Dim DB As DAO.Database
Set DB = OpenDatabase(filename)
prpB = Chr(91) & Me.prp & Chr(93)
Me.rval = DB.Properties!prpB
DB.Close
Set DB = Nothing

Me.prp is a ComboBox based on a query that lists valid property names, i.e.
AppIcon, AppTitle, etc.
prpB always returns "[somePropertyName]" which I think is correct. When code
goes to the next line, I get "Run-time Error 3270 Property not found". I do
know that refered property IS there.
It looks like some how Me.rval is ending up like Me.rval =
DB.Properties!"[AppIcon]" and thus ending up in error.
What am I doing wrong?
How can I bind the [xxxx] part to a variable?

Thanks in advance.

Alp
 
Try using a different method. Assuming Me.Prp is returning the name of the
property then you should be able to use:

DB.Properties(Me.Prp)
 
If refering to: DB.Properties!prpB returns "Run-time Error 3270 Property
not found", then, the property whose name is saved in variable prpB, does
not< exist as a database property: no two ways about it!

HTH,
TC


Alp Bekisoglu said:
Hi Experts,

I have the following code that refuses to work.
Dim DB As DAO.Database
Set DB = OpenDatabase(filename)
prpB = Chr(91) & Me.prp & Chr(93)
Me.rval = DB.Properties!prpB
DB.Close
Set DB = Nothing

Me.prp is a ComboBox based on a query that lists valid property names, i.e.
AppIcon, AppTitle, etc.
prpB always returns "[somePropertyName]" which I think is correct. When code
goes to the next line, I get "Run-time Error 3270 Property not found". I do
know that refered property IS there.
It looks like some how Me.rval is ending up like Me.rval =
DB.Properties!"[AppIcon]" and thus ending up in error.
What am I doing wrong?
How can I bind the [xxxx] part to a variable?

Thanks in advance.

Alp
 
Oops:

db.properties!prpB refers to a property named "prpB" (without the
quotes).

Your probably mean:

db.properties(prpB), which refers to the property whose name is in prpB.

And, that name should not contain any []s unless they are actually present
in the property name.

db.properties![blah] refers to a prop named "blah" (without the
quotes);

s = "[blah]"
db.properties(s) would refer to a prop named "[blah]" (without the
quotes) - not the same thing!

s = "bnlah"
db.propertiesa(s) refers to a prop named "blah" (ithout the quotes).

HTH,
TC
 
Hi TC and John,

First of all thanks for your advices.
Well, yes, after I logged out of the NG and quite sometime later, I finally
"did" find out that db.properties(whatever) does work! Why I had never tried
it before is still a puzzle. I guess that's what one gets if one starts an
Access career when one is at half a century! :-)
I needed it to check for versioning info.
Now I am fighting to find a way to (if possible) delete a property which I
had named wrongly... I might be barking up the wrong tree.... But will keep
trying. Or am I running after something that is impossible?

Thanks a lot for your time and advices guys.

Sincerely,

Alp
 
(snip)
Now I am fighting to find a way to (if possible) delete a property which I
had named wrongly

dim db as database
set db = currentdb()
db.properties.delete "blah"
set db = nothing

--or--

dbengine(0)(0).properties.delete "blah"

should do the job nicely.

HTH,
TC
 
Back
Top