Refering to an acObject with a Variable?

J

John

I have a table that stores the following in a field called ObjectType;
acForm, acReport, acQuery

I am trying to use a variable to call the ObjectType & place it in some
code.
But when the varibale is used, quotations are placed around the acObject.
Example:
objType = Recordset.Fields("ObjectType")
DoCmd.DeleteObject objType, "ObjectName"

When the code runs Quotations are plaed around the Variable objType
this causes my code to fail.
How do I avoid the quotes being placed around my Variable.

I hope all this makes sense.
Thanks
 
W

Wayne Morgan

The problem you are running into is that acForm, etc. are constants, not text strings. Go
to the debug window (Ctrl+G) and type

?acForm

to get the value of this constant. So, the final result is that you've placed a string
variable where a number should go.
 
J

John

Thanks Wayne
I changed the data in my field to the respective numbers of
each constant and the variable to an integer & it seems to work fine.
Thanks again
 

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