PC Review


Reply
Thread Tools Rate Thread

Creating fields in tdfNew

 
 
=?Utf-8?B?UGVuZHJhZ29u?=
Guest
Posts: n/a
 
      5th Nov 2007
Access03/WinXP

This should be fairly straightforward, so not sure what I am missing.
Looking at the help example for .CreateField (from the Northwind DB), I am
following the same format:

Set db = CurrentDb
set tdfNew = db.CreateTableDef("zTempBillInfo")

{definition of recordset}
rs.MoveFirst
With tdfNew
.Fields.Append .CreateField("ContactID", vbNumber)
.Fields.Append .CreateField("GroupA", vbCurrency)
...
End With

The code is bombing on the first .Fields.Append with an error "Data Type
Conversion Error" (#3421).

Ideas/suggestions?

Thanks.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGVuZHJhZ29u?=
Guest
Posts: n/a
 
      5th Nov 2007
Okay, I figured out the problem. For each field I was naming, I needed to
add the following line prior to the Append:

set fldName = tdfNew.CreateField(....)

and then after each instance I needed to have the tdfNew.Fields.Append fldName

Also, I discovered that the field definition is vbLong and vbNumber.

Works like a charm.

"Pendragon" wrote:

> Access03/WinXP
>
> This should be fairly straightforward, so not sure what I am missing.
> Looking at the help example for .CreateField (from the Northwind DB), I am
> following the same format:
>
> Set db = CurrentDb
> set tdfNew = db.CreateTableDef("zTempBillInfo")
>
> {definition of recordset}
> rs.MoveFirst
> With tdfNew
> .Fields.Append .CreateField("ContactID", vbNumber)
> .Fields.Append .CreateField("GroupA", vbCurrency)
> ...
> End With
>
> The code is bombing on the first .Fields.Append with an error "Data Type
> Conversion Error" (#3421).
>
> Ideas/suggestions?
>
> Thanks.
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      6th Nov 2007
With tdfNew
.Fields.Append .CreateField("ContactID", vbNumber)
.Fields.Append .CreateField("GroupA", vbCurrency)
...
End With

should work, but neither vbNumber or vbCurrency are valid (unless you've
declared them yourself). If ContactID is supposed to be a Long Integer, use
dbLong. Use dbCurrency for GroupA.



--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Pendragon" <(E-Mail Removed)> wrote in message
news:430FD72C-8FA9-4BFE-B83A-(E-Mail Removed)...
> Okay, I figured out the problem. For each field I was naming, I needed to
> add the following line prior to the Append:
>
> set fldName = tdfNew.CreateField(....)
>
> and then after each instance I needed to have the tdfNew.Fields.Append
> fldName
>
> Also, I discovered that the field definition is vbLong and vbNumber.
>
> Works like a charm.
>
> "Pendragon" wrote:
>
>> Access03/WinXP
>>
>> This should be fairly straightforward, so not sure what I am missing.
>> Looking at the help example for .CreateField (from the Northwind DB), I
>> am
>> following the same format:
>>
>> Set db = CurrentDb
>> set tdfNew = db.CreateTableDef("zTempBillInfo")
>>
>> {definition of recordset}
>> rs.MoveFirst
>> With tdfNew
>> .Fields.Append .CreateField("ContactID", vbNumber)
>> .Fields.Append .CreateField("GroupA", vbCurrency)
>> ...
>> End With
>>
>> The code is bombing on the first .Fields.Append with an error "Data Type
>> Conversion Error" (#3421).
>>
>> Ideas/suggestions?
>>
>> Thanks.
>>



 
Reply With Quote
 
=?Utf-8?B?UGVuZHJhZ29u?=
Guest
Posts: n/a
 
      6th Nov 2007
Sorry, that was a typo. I was using dbNumber and dbCurrency.

"Douglas J. Steele" wrote:

> With tdfNew
> .Fields.Append .CreateField("ContactID", vbNumber)
> .Fields.Append .CreateField("GroupA", vbCurrency)
> ...
> End With
>
> should work, but neither vbNumber or vbCurrency are valid (unless you've
> declared them yourself). If ContactID is supposed to be a Long Integer, use
> dbLong. Use dbCurrency for GroupA.
>
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Pendragon" <(E-Mail Removed)> wrote in message
> news:430FD72C-8FA9-4BFE-B83A-(E-Mail Removed)...
> > Okay, I figured out the problem. For each field I was naming, I needed to
> > add the following line prior to the Append:
> >
> > set fldName = tdfNew.CreateField(....)
> >
> > and then after each instance I needed to have the tdfNew.Fields.Append
> > fldName
> >
> > Also, I discovered that the field definition is vbLong and vbNumber.
> >
> > Works like a charm.
> >
> > "Pendragon" wrote:
> >
> >> Access03/WinXP
> >>
> >> This should be fairly straightforward, so not sure what I am missing.
> >> Looking at the help example for .CreateField (from the Northwind DB), I
> >> am
> >> following the same format:
> >>
> >> Set db = CurrentDb
> >> set tdfNew = db.CreateTableDef("zTempBillInfo")
> >>
> >> {definition of recordset}
> >> rs.MoveFirst
> >> With tdfNew
> >> .Fields.Append .CreateField("ContactID", vbNumber)
> >> .Fields.Append .CreateField("GroupA", vbCurrency)
> >> ...
> >> End With
> >>
> >> The code is bombing on the first .Fields.Append with an error "Data Type
> >> Conversion Error" (#3421).
> >>
> >> Ideas/suggestions?
> >>
> >> Thanks.
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add records to tdfNew as TableDef =?Utf-8?B?UGVuZHJhZ29u?= Microsoft Access VBA Modules 2 20th Feb 2007 04:46 PM
Creating fields =?Utf-8?B?R2lsYmVydCAyMDk3?= Microsoft Access VBA Modules 2 6th Oct 2006 01:26 PM
Auto creating text fields when creating new slide. =?Utf-8?B?amFtZXM=?= Microsoft Powerpoint 1 16th Jun 2005 04:02 PM
creating new fields =?Utf-8?B?cHV6emxlZA==?= Microsoft Access Getting Started 1 15th Jun 2004 11:55 PM
creating new fields jcj Microsoft Outlook Contacts 1 1st Jul 2003 07:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:46 PM.