A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Type Conversion Failure Error



 
 
Thread Tools Display Modes
  #1  
Old September 22nd, 2009, 05:41 PM posted to microsoft.public.access.queries
Jon22
external usenet poster
 
Posts: 36
Default Type Conversion Failure Error

I keep getting a Type Conversion Failure error when I run a particular append
query. Four of the fields being appended are derived from Expressions. I've
worked out that two of these four Exp fields are my culprits. if I remove
these the append query runs. The expressions of these two problematic fields
are merely references to text fields in an open form. Should they not work
too? I really need them in there.
  #2  
Old September 22nd, 2009, 05:59 PM posted to microsoft.public.access.queries
Clifford Bass[_2_]
external usenet poster
 
Posts: 1,295
Default Type Conversion Failure Error

Hi,

Try wrapping the results of your expressions with one of the Cxxx()
functions. For example, if you want to make sure that the expression results
in a double value you might use CDbl().

If you need further help, post back with your query's SQL and
information about the types of values that are causing trouble. Also,
indicate if any of those expressions use fields or form data that can be null.

Clifford Bass

"Jon22" wrote:

I keep getting a Type Conversion Failure error when I run a particular append
query. Four of the fields being appended are derived from Expressions. I've
worked out that two of these four Exp fields are my culprits. if I remove
these the append query runs. The expressions of these two problematic fields
are merely references to text fields in an open form. Should they not work
too? I really need them in there.

  #3  
Old September 22nd, 2009, 06:57 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Type Conversion Failure Error

On Tue, 22 Sep 2009 09:41:02 -0700, Jon22
wrote:

I keep getting a Type Conversion Failure error when I run a particular append
query. Four of the fields being appended are derived from Expressions. I've
worked out that two of these four Exp fields are my culprits. if I remove
these the append query runs. The expressions of these two problematic fields
are merely references to text fields in an open form. Should they not work
too? I really need them in there.


Correct the error in your expressions. For help doing so please post the SQL
of the query and indicate the datatype of the fields you're trying to append
to.
--

John W. Vinson [MVP]
  #4  
Old September 23rd, 2009, 03:30 AM posted to microsoft.public.access.queries
Jon22
external usenet poster
 
Posts: 36
Default Type Conversion Failure Error

Thanks, I would have posted it before but it was enormous. This is it with
the four expression fields and a couple of the straight field to field ones.
(sorry, about my poor terminology):

INSERT INTO [Quotes Sub] ( [Quote Number], Customer, [Order], [Sub Date],
[Design Number], [Unit Cost], [Unit Sale], [Unit Profit], Quantity, [QS
Number] )
SELECT DISTINCT [Forms]![Quotes New]![Quote Number] AS [Quote Number],
[Forms]![Quotes New]![Customer] AS Customer, Nz(DMax("[Order]","[Quotes
Sub]","[Quote Number]=Forms![Quotes New]![Quote Number]"),0)+1 AS [Order],
Date() AS [Sub Date], [Quotes Sub].[Design Number], [Quotes Sub].[Unit Cost],
[Quotes Sub].[Unit Sale], [Quotes Sub].[Unit Profit], [Quotes Sub].Quantity,
[Quotes Sub].[QS Number]
FROM [Quotes Sub]
WHERE ((([Quotes Sub].[QS Number])=[Forms]![Quotes New - Copy Sub]![QS
Number List]));

The two problem ones are [Quote Number] and [Customer]. Both of which are
just text fields in the form "Quotes New"

I have got around it by using a third SQL statement which uses the above
query name ("Copy Sub - Selected") adding the two problem fields separately
like this:

DoCmd.RunSQL "INSERT INTO [Quotes Sub] ( Customer, [Quote Number] )" & _
"SELECT [Copy Sub - Selected].*, [Forms]![Quotes New]![Customer]
AS Customer, [Forms]![Quotes New]![Quote Number] AS [Quote Number]" & _
"FROM [Copy Sub - Selected]"

It probably isn't the most efficient way to do it though. I did come across
an article he

http://support.microsoft.com/kb/125259

which might have something to do with it.


"John W. Vinson" wrote:

On Tue, 22 Sep 2009 09:41:02 -0700, Jon22
wrote:

I keep getting a Type Conversion Failure error when I run a particular append
query. Four of the fields being appended are derived from Expressions. I've
worked out that two of these four Exp fields are my culprits. if I remove
these the append query runs. The expressions of these two problematic fields
are merely references to text fields in an open form. Should they not work
too? I really need them in there.


Correct the error in your expressions. For help doing so please post the SQL
of the query and indicate the datatype of the fields you're trying to append
to.
--

John W. Vinson [MVP]

  #5  
Old September 23rd, 2009, 07:15 PM posted to microsoft.public.access.queries
Clifford Bass[_2_]
external usenet poster
 
Posts: 1,295
Default Type Conversion Failure Error

Hi,

Are the Customer and Quote Number on the form formatted as numbers? If
not, you might try setting their Format properties to an appropriate numeric
format.

Clifford Bass

"Jon22" wrote:

Thanks, I would have posted it before but it was enormous. This is it with
the four expression fields and a couple of the straight field to field ones.
(sorry, about my poor terminology):

INSERT INTO [Quotes Sub] ( [Quote Number], Customer, [Order], [Sub Date],
[Design Number], [Unit Cost], [Unit Sale], [Unit Profit], Quantity, [QS
Number] )
SELECT DISTINCT [Forms]![Quotes New]![Quote Number] AS [Quote Number],
[Forms]![Quotes New]![Customer] AS Customer, Nz(DMax("[Order]","[Quotes
Sub]","[Quote Number]=Forms![Quotes New]![Quote Number]"),0)+1 AS [Order],
Date() AS [Sub Date], [Quotes Sub].[Design Number], [Quotes Sub].[Unit Cost],
[Quotes Sub].[Unit Sale], [Quotes Sub].[Unit Profit], [Quotes Sub].Quantity,
[Quotes Sub].[QS Number]
FROM [Quotes Sub]
WHERE ((([Quotes Sub].[QS Number])=[Forms]![Quotes New - Copy Sub]![QS
Number List]));

The two problem ones are [Quote Number] and [Customer]. Both of which are
just text fields in the form "Quotes New"

I have got around it by using a third SQL statement which uses the above
query name ("Copy Sub - Selected") adding the two problem fields separately
like this:

DoCmd.RunSQL "INSERT INTO [Quotes Sub] ( Customer, [Quote Number] )" & _
"SELECT [Copy Sub - Selected].*, [Forms]![Quotes New]![Customer]
AS Customer, [Forms]![Quotes New]![Quote Number] AS [Quote Number]" & _
"FROM [Copy Sub - Selected]"

It probably isn't the most efficient way to do it though. I did come across
an article he

http://support.microsoft.com/kb/125259

which might have something to do with it.

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:09 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.