Sign Up |  Live StatsLive Stats    Articles 35,345| Comments 159,788| Members 17,820, Newest waheguruhelpme| Online 220
Home Contact
 (Forgotten?): 
    Sikhism

   
                                                                     Your Banner Here!    

Sikh Philosophy Network » Sikh Philosophy Network » Current Affairs » Information Technology » Getting error because query contains a function

Getting error because query contains a function

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 400 USD, Received: 35 USD (9%)
Please Donate...
Related Topics...
Thread Thread Starter Forum Replies Last Post
Error 3085: Undefined function 'StrReverse' in expression. Teresa Information Technology 10 28-Jul-2006 08:36 AM
Format function failing in SQL query millardgroups@gmail.com Information Technology 1 28-Jul-2006 08:14 AM
InStr function error driving me around the bend. DaBartman Information Technology 4 28-Jul-2006 08:13 AM
Problem with function in query Jürg Leuenberger Information Technology 2 11-Nov-2005 20:09 PM
Trying to Using a Query and a Dlookup function patentinv Information Technology 3 30-Oct-2005 12:47 PM


Tags
getting, error, because, query, contains, function
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 28-Jul-2006, 08:18 AM
Domac's Avatar Domac
Guest
 
Posts: n/a
   
   
Getting error because query contains a function

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
Hi,

Query named "qdfProizvodiAnalitikaZadnje" is using function to define value
in a field ..

When I execute this query from code i get message "Undefined function
'FormatNumberAsString' in expression"!

Why ??

When I execute it whitin query designer everything works fine!


Here is part of code:


strSql = "SELECT qdfProizvodiAnalitikaZadnje.* " & _
"FROM qdfProizvodiAnalitikaZadnje " & _
"WHERE (((qdfProizvodiAnalitikaZadnje.VEZA)=" & VezaPodEntiteta &
"));"



Set rst = CurrentDb.OpenRecordset(strSql, dbOpenSnapshot)



Here is SQL of query that I mention above:

SELECT ProizvodiSifreRangovi.VEZA,
ProizvodiSifreRangovi.ENTITET,
ProizvodiSifreRangovi.OPIS,
ProizvodiSifreRangovi.START,
ProizvodiSifreRangovi.END,
IIf(IsNull([qdfProizvodiSifreZadnje]![UpisanoSifri]),"0",[qdfProizvodiSifreZadnje]![UpisanoSifri])
AS UpisanoSifri,
IIf(IsNull([qdfProizvodiSifreZadnje]![SlijedeciIndex]),[ProizvodiSifreRangovi]![START],[qdfProizvodiSifreZadnje]![SlijedeciIndex])
AS SlijedeciIndex,
[ProizvodiSifreRangovi]![ENTITET] & FormatNumberAsString([SlijedeciIndex])
AS SlijedecaSifra,

Switch([SlijedeciIndex]<[ProizvodiSifreRangovi]![START],"Ne",[SlijedeciIndex]>[ProizvodiSifreRangovi]![END],"Ne",[SlijedeciIndex]>=[ProizvodiSifreRangovi]![START]
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/11122-getting-error-because-query-contains-function.html
And [SlijedeciIndex]<=[ProizvodiSifreRangovi]![END],"Da") AS UnutarRanga,

IIf([SlijedeciIndex]=([ProizvodiSifreRangovi]![START]+[UpisanoSifri]),"Da","Ne")
AS Konzistentan

FROM ProizvodiSifreRangovi LEFT JOIN qdfProizvodiSifreZadnje ON
ProizvodiSifreRangovi.VEZA = qdfProizvodiSifreZadnje.VEZA
GROUP BY ProizvodiSifreRangovi.VEZA, ProizvodiSifreRangovi.ENTITET,
ProizvodiSifreRangovi.OPIS, ProizvodiSifreRangovi.START,
ProizvodiSifreRangovi.END,
IIf(IsNull([qdfProizvodiSifreZadnje]![UpisanoSifri]),"0",[qdfProizvodiSifreZadnje]![UpisanoSifri]),
IIf(IsNull([qdfProizvodiSifreZadnje]![SlijedeciIndex]),[ProizvodiSifreRangovi]![START],[qdfProizvodiSifreZadnje]![SlijedeciIndex])
HAVING (((ProizvodiSifreRangovi.VEZA)<>0));


here is function FormatNumberAsString:
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11122

Public Function FormatNumberAsString(number As Long, Optional lenght As
Long) As String

'Po zadnjem pravilniku o ¹ifriranju
Dim lngLenght As Long
Dim strNumber As String 'Broj æe se konvertirati u string i ovisno o duljini
kreirati string popunjen nulama na glavi
Dim lngNumberLen As Long
Dim lngZeroAddendum As Long


'Provjeri bitno!
If IsMissing(lenght) Or lenght = 0 Then 'ako lenght nije upisan
'Po pravilniku o ¹ifriranju!
lngLenght = 5
Else
'Ako je poslan (izvanrednost)
lngLenght = lenght
End If

strNumber = CStr(number)
lngNumberLen = Len(strNumber)


'Razlika duljine opæenito minus duljine broja daje broj 0 koje se dodaju na
glavu stringa!
lngZeroAddendum = lngLenght - lngNumberLen

If lngZeroAddendum < 0 Then lngZeroAddendum = 0




FormatNumberAsString = String(lngZeroAddendum, "0") & strNumber





End Function








 
Do share your immediate thoughts or reactions on this issue? We value your views! Login Now! or Sign Up Today! to share your views with us.. Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 28-Jul-2006, 08:18 AM
Danny J. Lesandrini's Avatar Danny J. Lesandrini
Guest
 
Posts: n/a
   
   
Re: Getting error because query contains a function

What do you mean when you say, "when I execute the query from code ..."?
Show the code you're using to execute the function and maybe that will help.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11122
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11122
--

Danny J. Lesandrini
dlesandrini@hotmail.com
http://amazecreations.com/datafast


"Domac" wrote ...
> Hi,
>
> Query named "qdfProizvodiAnalitikaZadnje" is using function to define value in a field ..
>
> When I execute this query from code i get message "Undefined function 'FormatNumberAsString' in expression"!
>
> Why ??
>
> When I execute it whitin query designer everything works fine!
>
>
> Here is part of code:
>
>
> strSql = "SELECT qdfProizvodiAnalitikaZadnje.* " & _
> "FROM qdfProizvodiAnalitikaZadnje " & _
> "WHERE (((qdfProizvodiAnalitikaZadnje.VEZA)=" & VezaPodEntiteta & "));"



Reply With Quote
  #3 (permalink)  
Old 28-Jul-2006, 08:18 AM
Domac's Avatar Domac
Guest
 
Posts: n/a
   
   
Re: Getting error because query contains a function

Look inside SQL text at bottom of my root post!

Function is named 'FormatNumberAsString' and it is used to define value of
expression of field named 'SlijedecaSifra'.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11122


Here is sql again:

SELECT ProizvodiSifreRangovi.VEZA,
ProizvodiSifreRangovi.ENTITET,
ProizvodiSifreRangovi.OPIS,
ProizvodiSifreRangovi.START,
ProizvodiSifreRangovi.END,
IIf(IsNull([qdfProizvodiSifreZadnje]![UpisanoSifri]),"0",[qdfProizvodiSifreZadnje]![UpisanoSifri])
AS UpisanoSifri,
IIf(IsNull([qdfProizvodiSifreZadnje]![SlijedeciIndex]),[ProizvodiSifreRangovi]![START],[qdfProizvodiSifreZadnje]![SlijedeciIndex])
AS SlijedeciIndex,
[ProizvodiSifreRangovi]![ENTITET] & FormatNumberAsString([SlijedeciIndex])
AS SlijedecaSifra,

Switch([SlijedeciIndex]<[ProizvodiSifreRangovi]![START],"Ne",[SlijedeciIndex]>[ProizvodiSifreRangovi]![END],"Ne",[SlijedeciIndex]>=[ProizvodiSifreRangovi]![START]
And [SlijedeciIndex]<=[ProizvodiSifreRangovi]![END],"Da") AS UnutarRanga,

IIf([SlijedeciIndex]=([ProizvodiSifreRangovi]![START]+[UpisanoSifri]),"Da","Ne")
AS Konzistentan

FROM ProizvodiSifreRangovi LEFT JOIN qdfProizvodiSifreZadnje ON
ProizvodiSifreRangovi.VEZA = qdfProizvodiSifreZadnje.VEZA
GROUP BY ProizvodiSifreRangovi.VEZA, ProizvodiSifreRangovi.ENTITET,
ProizvodiSifreRangovi.OPIS, ProizvodiSifreRangovi.START,
ProizvodiSifreRangovi.END,
IIf(IsNull([qdfProizvodiSifreZadnje]![UpisanoSifri]),"0",[qdfProizvodiSifreZadnje]![UpisanoSifri]),
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11122
IIf(IsNull([qdfProizvodiSifreZadnje]![SlijedeciIndex]),[ProizvodiSifreRangovi]![START],[qdfProizvodiSifreZadnje]![SlijedeciIndex])
HAVING (((ProizvodiSifreRangovi.VEZA)<>0));





Reply With Quote
  #4 (permalink)  
Old 28-Jul-2006, 08:18 AM
Danny J. Lesandrini's Avatar Danny J. Lesandrini
Guest
 
Posts: n/a
   
   
Re: Getting error because query contains a function

I'm sorry, I wasn't clear. You said that you can run the query from
the design window and it works. Great! So what's the problem?

The problem must have to do with how you're executing the query
when NOT in the QBE window. How are you trying to launch it?
--

Danny J. Lesandrini
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11122
dlesandrini@hotmail.com
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11122
http://amazecreations.com/datafast


Reply With Quote
  #5 (permalink)  
Old 28-Jul-2006, 08:18 AM
Brendan Reynolds's Avatar Brendan Reynolds
Guest
 
Posts: n/a
   
   
Re: Getting error because query contains a function

If I understand the code and SQL you posted correctly, I'm not sure that you
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11122
actually need the function at all. I think you can achieve the same thing
with an expression in the query ...

SELECT tblTest.TestNumber, Format$(NZ([TestNumber], 0), String$([How Many?],
"0")) AS Expr1
FROM tblTest;

Here the parameter '[How Many?]' performs the same function as the optional
argument in your function.

Here's an example of how you might use it ...

Public Sub TestQuery()

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim fld As DAO.Field

Set db = CurrentDb
Set qdf = db.QueryDefs("qryTest")
qdf.Parameters("[How Many?]") = 5
Set rst = qdf.OpenRecordset()
Do Until rst.EOF
For Each fld In rst.Fields
Debug.Print fld.Value
Next fld
rst.MoveNext
Loop
rst.Close

End Sub

--
Brendan Reynolds
Access MVP


"Domac" wrote in message
news:uChTj67iGHA.4368@TK2MSFTNGP03.phx.gbl...
> Hi,
>
> Query named "qdfProizvodiAnalitikaZadnje" is using function to define
> value in a field ..
>
> When I execute this query from code i get message "Undefined function
> 'FormatNumberAsString' in expression"!
>
> Why ??
>
> When I execute it whitin query designer everything works fine!
>
>
> Here is part of code:
>
>
> strSql = "SELECT qdfProizvodiAnalitikaZadnje.* " & _
> "FROM qdfProizvodiAnalitikaZadnje " & _
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11122
> "WHERE (((qdfProizvodiAnalitikaZadnje.VEZA)=" & VezaPodEntiteta &
> "));"
>
>
>
> Set rst = CurrentDb.OpenRecordset(strSql, dbOpenSnapshot)
>
>
>
> Here is SQL of query that I mention above:
>
> SELECT ProizvodiSifreRangovi.VEZA,
> ProizvodiSifreRangovi.ENTITET,
> ProizvodiSifreRangovi.OPIS,
> ProizvodiSifreRangovi.START,
> ProizvodiSifreRangovi.END,
> IIf(IsNull([qdfProizvodiSifreZadnje]![UpisanoSifri]),"0",[qdfProizvodiSifreZadnje]![UpisanoSifri])
> AS UpisanoSifri,
> IIf(IsNull([qdfProizvodiSifreZadnje]![SlijedeciIndex]),[ProizvodiSifreRangovi]![START],[qdfProizvodiSifreZadnje]![SlijedeciIndex])
> AS SlijedeciIndex,
> [ProizvodiSifreRangovi]![ENTITET] & FormatNumberAsString([SlijedeciIndex])
> AS SlijedecaSifra,
>
> Switch([SlijedeciIndex]<[ProizvodiSifreRangovi]![START],"Ne",[SlijedeciIndex]>[ProizvodiSifreRangovi]![END],"Ne",[SlijedeciIndex]>=[ProizvodiSifreRangovi]![START]
> And [SlijedeciIndex]<=[ProizvodiSifreRangovi]![END],"Da") AS UnutarRanga,
>
> IIf([SlijedeciIndex]=([ProizvodiSifreRangovi]![START]+[UpisanoSifri]),"Da","Ne")
> AS Konzistentan
>
> FROM ProizvodiSifreRangovi LEFT JOIN qdfProizvodiSifreZadnje ON
> ProizvodiSifreRangovi.VEZA = qdfProizvodiSifreZadnje.VEZA
> GROUP BY ProizvodiSifreRangovi.VEZA, ProizvodiSifreRangovi.ENTITET,
> ProizvodiSifreRangovi.OPIS, ProizvodiSifreRangovi.START,
> ProizvodiSifreRangovi.END,
> IIf(IsNull([qdfProizvodiSifreZadnje]![UpisanoSifri]),"0",[qdfProizvodiSifreZadnje]![UpisanoSifri]),
> IIf(IsNull([qdfProizvodiSifreZadnje]![SlijedeciIndex]),[ProizvodiSifreRangovi]![START],[qdfProizvodiSifreZadnje]![SlijedeciIndex])
> HAVING (((ProizvodiSifreRangovi.VEZA)<>0));
>
>
> here is function FormatNumberAsString:
>
> Public Function FormatNumberAsString(number As Long, Optional lenght As
> Long) As String
>
> 'Po zadnjem pravilniku o ¹ifriranju
> Dim lngLenght As Long
> Dim strNumber As String 'Broj æe se konvertirati u string i ovisno o
> duljini kreirati string popunjen nulama na glavi
> Dim lngNumberLen As Long
> Dim lngZeroAddendum As Long
>
>
> 'Provjeri bitno!
> If IsMissing(lenght) Or lenght = 0 Then 'ako lenght nije upisan
> 'Po pravilniku o ¹ifriranju!
> lngLenght = 5
> Else
> 'Ako je poslan (izvanrednost)
> lngLenght = lenght
> End If
>
> strNumber = CStr(number)
> lngNumberLen = Len(strNumber)
>
>
> 'Razlika duljine opæenito minus duljine broja daje broj 0 koje se dodaju
> na glavu stringa!
> lngZeroAddendum = lngLenght - lngNumberLen
>
> If lngZeroAddendum < 0 Then lngZeroAddendum = 0
>
>
>
>
> FormatNumberAsString = String(lngZeroAddendum, "0") & strNumber
>
>
>
>
>
> End Function
>
>
>



Reply With Quote
  #6 (permalink)  
Old 28-Jul-2006, 08:18 AM
SusanV's Avatar SusanV
Guest
 
Posts: n/a
   
   
Re: Getting error because query contains a function

  Donate Today!  
Are you trying to run this using DoCmd.RunSQL? Because you can only run
action queries via DoCmd (Insert, Append, etc, not SELECT). Instead of using
docmd, use a recordset instead, with your query as the datasource.
--
hth,
SusanV

"Domac" wrote in message
news:uHDuiG8iGHA.2188@TK2MSFTNGP04.phx.gbl...
> Look inside SQL text at bottom of my root post!
>
> Function is named 'FormatNumberAsString' and it is used to define value
> of expression of field named 'SlijedecaSifra'.
>
>
> Here is sql again:
>
> SELECT ProizvodiSifreRangovi.VEZA,
> ProizvodiSifreRangovi.ENTITET,
> ProizvodiSifreRangovi.OPIS,
> ProizvodiSifreRangovi.START,
> ProizvodiSifreRangovi.END,
> IIf(IsNull([qdfProizvodiSifreZadnje]![UpisanoSifri]),"0",[qdfProizvodiSifreZadnje]![UpisanoSifri])
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11122
> AS UpisanoSifri,
> IIf(IsNull([qdfProizvodiSifreZadnje]![SlijedeciIndex]),[ProizvodiSifreRangovi]![START],[qdfProizvodiSifreZadnje]![SlijedeciIndex])
> AS SlijedeciIndex,
> [ProizvodiSifreRangovi]![ENTITET] & FormatNumberAsString([SlijedeciIndex])
> AS SlijedecaSifra,
>
> Switch([SlijedeciIndex]<[ProizvodiSifreRangovi]![START],"Ne",[SlijedeciIndex]>[ProizvodiSifreRangovi]![END],"Ne",[SlijedeciIndex]>=[ProizvodiSifreRangovi]![START]
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=11122
> And [SlijedeciIndex]<=[ProizvodiSifreRangovi]![END],"Da") AS UnutarRanga,
>
> IIf([SlijedeciIndex]=([ProizvodiSifreRangovi]![START]+[UpisanoSifri]),"Da","Ne")
> AS Konzistentan
>
> FROM ProizvodiSifreRangovi LEFT JOIN qdfProizvodiSifreZadnje ON
> ProizvodiSifreRangovi.VEZA = qdfProizvodiSifreZadnje.VEZA
> GROUP BY ProizvodiSifreRangovi.VEZA, ProizvodiSifreRangovi.ENTITET,
> ProizvodiSifreRangovi.OPIS, ProizvodiSifreRangovi.START,
> ProizvodiSifreRangovi.END,
> IIf(IsNull([qdfProizvodiSifreZadnje]![UpisanoSifri]),"0",[qdfProizvodiSifreZadnje]![UpisanoSifri]),
> IIf(IsNull([qdfProizvodiSifreZadnje]![SlijedeciIndex]),[ProizvodiSifreRangovi]![START],[qdfProizvodiSifreZadnje]![SlijedeciIndex])
> HAVING (((ProizvodiSifreRangovi.VEZA)<>0));
>
>
>
>
>



Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

Advanced Search
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

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

» Gurbani Jukebox
Listen to Gurbani while surfing SPN!
» Active Discussions
sikhism Who is "Mohan"?
Today 06:52 AM
21 Replies, 319 Views
sikhism need urgent advice.......
Today 06:46 AM
6 Replies, 72 Views
sikhism ਨਾਮਾ
Today 06:37 AM
2 Replies, 45 Views
sikhism Sikh Diamonds Video...
Today 04:23 AM
6 Replies, 112 Views
sikhism Are Creator and Creation...
Today 01:30 AM
44 Replies, 2,833 Views
sikhism Herman Hesse,...
Today 00:54 AM
13 Replies, 225 Views
sikhism On a Scale of Most...
Yesterday 21:42 PM
30 Replies, 1,277 Views
sikhism I became victim by...
Yesterday 19:50 PM
0 Replies, 39 Views
sikhism How important is Matha...
By Ishna
Yesterday 19:05 PM
58 Replies, 1,026 Views
sikhism Sikh Books downloads
Yesterday 15:39 PM
2 Replies, 62 Views
sikhism Salok Sheikh Farid ji...
Yesterday 09:35 AM
0 Replies, 43 Views
sikhism In Punjab, three farmers...
Yesterday 05:36 AM
0 Replies, 45 Views
sikhism Supernatural Sikhs, what...
Yesterday 03:45 AM
19 Replies, 408 Views
sikhism Sukhmani Sahib Astpadi...
26-May-2012 22:57 PM
0 Replies, 46 Views
Do You Think You Are...
26-May-2012 09:59 AM
94 Replies, 8,258 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.2

All times are GMT +6.5. The time now is 07:16 AM.
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 1.13102 seconds with 30 queries