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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to judge whether a field is already added into a table?

Status
Not open for further replies.

ArmstrongHe

IS-IT--Management
Oct 27, 2003
22
CN
Hi, Gang,
Another beautiful Day for you and me in this tips-land!

The question is, How to judge whether a field is already added into a table?

For example, part of coding like this:

qname = "alter table " & ii & " add mayqty double;"
myDb.Execute qname, dbFailOnError

but an error will occur if "mayqty" already exist there.

I want to use an "if" statement to judge whether that field is already added or not.

Your kind help would be very appreciated.
Armstrong
 
Hi

For the code snippit you give I am not sure if you are using DAO or ADO, I suspect you are using ADO, either way why not test the fields collection of the recordset (table) to see if the field is there

eg refer to Rs.Fields("mayqty") and trap the resulting error if not found, no error means its there



Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi, KenReay,
Thank you very much!
I am a beginner. I have two further questions:
1. How to check whether I am using ADO or DAO if I have just used "dim RS as recordset"? I only know I am using ACCESS-XP.
2. "trap resulting error" means that I should use an "on error goto..." statement? What should that look like?

Thanks!
Armstrong
 
Hi

In AccessXP (2002) ADO is the default data access library, so unless you have explicitly set a reference to DAO you are using ADO

On Error Go To, see help for possible syntax variations and examples

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi,Ken,
I just want to explore a more precise way to judge whether a field does exist or not, sth like a function that looks like "isfield(mayqty)", or some other coding method. It's not easy to find that out?

I have seen your personal website. It's last updated in 2000? Now you are a Freelance? Boldon IS Ltd is your own company or just the web-maker?

I am working in GuangZhou, China, Have you been here?

Best Regards!
Armstrong

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top