Repost: Adding New Fields to Tables using Code

R

Richard Krupa

Hi Guys,

I'm writting a small program to update tables with the new fields to save
sometime. Its all working except when it comes to adding a new field thats
of a number type.

The problem is trying to set the decimal places, i'm using:

Set prp = fld.CreateProperty("Decimal Places", dbInteger,
myRs!FieldDecPlace)
fld.Properties.Append prp

myrs!FieldDecPlace = 2

myrs!FieldDecPlace = a value that comes from the NewFields table that stores
the info for the new fields, it just loops through the records in the table.

Thanks in advance
--
Regards,
Richard


--
Regards,
Richard S Krupa
--------------------------------------------------------
Senior Software Engineer
Merlin Point of Sale Development Team
Daak Computer Systems Pty Ltd
Phone: +61 (07) 3392 8699
E-mail: (e-mail address removed)
Webpage: www.merlinpos.com.au
--------------------------------------------------------

WARNING: This e-mail contains information which is CONFIDENTIAL and may be
subject to LEGAL PRIVILEGE. If you are not the intended recipient, you must
not peruse, use, disseminate, distribute or copy this e-mail or attachments.
If you have received this in error, please notify us immediately by return
e-mail and delete this e-mail. You DON'T have permission to forward this
e-mail
on. Thank you.

"Merlin Point of Sale Systems" is a registered Business Name of Daak
Computers Pty Ltd
 
R

Ruskin Hardie

You are creating a field 'Decimal Places', but are making it an integer
type... standard integer and long integer, do NOT accept decimal places. You
may want to try dbDouble....
 
R

Richard Krupa

Thanks for the reply Ruskin but its still now working. I'm setting the
decimal place to 2 but when the field gets added the decimal place is still
"Auto"

Regards
Richard
 
G

Graham Mandeno

Hi Richard

I suspect you need to lose the space between "Decimal" and "Places".

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.
 
R

Richard Krupa

Hi Graham,

Ive tried that just then and its still not working

This the current syntax im using:

Set prp = fld.CreateProperty("DecimalPlaces", dbDouble,
myRs!FieldDecPlace)
fld.Properties.Append prp

FieldDecPlace = 2

Regards,
Richard

Graham Mandeno said:
Hi Richard

I suspect you need to lose the space between "Decimal" and "Places".

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.

Richard Krupa said:
Hi Guys,

I'm writting a small program to update tables with the new fields to save
sometime. Its all working except when it comes to adding a new field thats
of a number type.

The problem is trying to set the decimal places, i'm using:

Set prp = fld.CreateProperty("Decimal Places", dbInteger,
myRs!FieldDecPlace)
fld.Properties.Append prp

myrs!FieldDecPlace = 2

myrs!FieldDecPlace = a value that comes from the NewFields table that stores
the info for the new fields, it just loops through the records in the table.

Thanks in advance
--
Regards,
Richard


--
Regards,
Richard S Krupa
--------------------------------------------------------
Senior Software Engineer
Merlin Point of Sale Development Team
Daak Computer Systems Pty Ltd
Phone: +61 (07) 3392 8699
E-mail: (e-mail address removed)
Webpage: www.merlinpos.com.au
--------------------------------------------------------

WARNING: This e-mail contains information which is CONFIDENTIAL and may be
subject to LEGAL PRIVILEGE. If you are not the intended recipient, you must
not peruse, use, disseminate, distribute or copy this e-mail or attachments.
If you have received this in error, please notify us immediately by return
e-mail and delete this e-mail. You DON'T have permission to forward this
e-mail
on. Thank you.

"Merlin Point of Sale Systems" is a registered Business Name of Daak
Computers Pty Ltd
 
R

Ruskin Hardie

Oopsss.... sorry, read your code a bit closer. You are correct, when you are
creating a property, as an integer (not the data type of the field). My
mistake... However, the DecimalPlaces is a user-defined property. To adjust
the decimal places, I think you need to use the existing properties and I
think it is the size property that you are after...
 
G

Graham Mandeno

Hi Richard

When Access creates the DecimalPlaces property, it's a byte, not a double.
Try:
fld.CreateProperty("DecimalPlaces", dbByte, myRs!FieldDecPlace)

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.

Richard Krupa said:
Hi Graham,

Ive tried that just then and its still not working

This the current syntax im using:

Set prp = fld.CreateProperty("DecimalPlaces", dbDouble,
myRs!FieldDecPlace)
fld.Properties.Append prp

FieldDecPlace = 2

Regards,
Richard

Graham Mandeno said:
Hi Richard

I suspect you need to lose the space between "Decimal" and "Places".

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.

Richard Krupa said:
Hi Guys,

I'm writting a small program to update tables with the new fields to save
sometime. Its all working except when it comes to adding a new field thats
of a number type.

The problem is trying to set the decimal places, i'm using:

Set prp = fld.CreateProperty("Decimal Places", dbInteger,
myRs!FieldDecPlace)
fld.Properties.Append prp

myrs!FieldDecPlace = 2

myrs!FieldDecPlace = a value that comes from the NewFields table that stores
the info for the new fields, it just loops through the records in the table.

Thanks in advance
--
Regards,
Richard


--
Regards,
Richard S Krupa
--------------------------------------------------------
Senior Software Engineer
Merlin Point of Sale Development Team
Daak Computer Systems Pty Ltd
Phone: +61 (07) 3392 8699
E-mail: (e-mail address removed)
Webpage: www.merlinpos.com.au
may
 
R

Ruskin Hardie

Yup, think Graham is correct.. Have just done a quick check on;

For myCnt = 0 To myFld.Properties.Count - 1
Debug.Print myFld.Properties(myCnt).Name, _
myFld.Properties(myCnt).Type
Next myCnt

When I did it, with the field set to Auto, there was no DecimalPlaces
property, with the field set to 2, the DecimalPlaces property (with no
spaces), was set to a type of 2.... Not sure what the constant value of
dbInteger is, but you may want to try dbByte...
 
R

Richard Krupa

Cheers guys you have been a great help :)

Have a good weekend!

Regards,
Richard

Graham Mandeno said:
Hi Richard

When Access creates the DecimalPlaces property, it's a byte, not a double.
Try:
fld.CreateProperty("DecimalPlaces", dbByte, myRs!FieldDecPlace)

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.

Richard Krupa said:
Hi Graham,

Ive tried that just then and its still not working

This the current syntax im using:

Set prp = fld.CreateProperty("DecimalPlaces", dbDouble,
myRs!FieldDecPlace)
fld.Properties.Append prp

FieldDecPlace = 2

Regards,
Richard

Graham Mandeno said:
Hi Richard

I suspect you need to lose the space between "Decimal" and "Places".

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.

Hi Guys,

I'm writting a small program to update tables with the new fields to save
sometime. Its all working except when it comes to adding a new field thats
of a number type.

The problem is trying to set the decimal places, i'm using:

Set prp = fld.CreateProperty("Decimal Places", dbInteger,
myRs!FieldDecPlace)
fld.Properties.Append prp

myrs!FieldDecPlace = 2

myrs!FieldDecPlace = a value that comes from the NewFields table that
stores
the info for the new fields, it just loops through the records in the
table.

Thanks in advance
--
Regards,
Richard


--
Regards,
Richard S Krupa
--------------------------------------------------------
Senior Software Engineer
Merlin Point of Sale Development Team
Daak Computer Systems Pty Ltd
Phone: +61 (07) 3392 8699
E-mail: (e-mail address removed)
Webpage: www.merlinpos.com.au
may
be
subject to LEGAL PRIVILEGE. If you are not the intended recipient, you
must
not peruse, use, disseminate, distribute or copy this e-mail or
attachments.
If you have received this in error, please notify us immediately by return
e-mail and delete this e-mail. You DON'T have permission to forward this
e-mail
on. Thank you.

"Merlin Point of Sale Systems" is a registered Business Name of Daak
Computers Pty Ltd
 

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