Module not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am a new Access user, and am using access 97. I am working on setting up a
callout list where the order is determined by overtime hours worked. I set
upa query that adds the hours at start of pay period with the hours worked
and gets total then sorts it. I then need it to show the updated place in
the order. I found a funtion that does that in another post here, but when I
put the funtion in a module and called it in the query, I get an error
stating undefined funtion. Thanks for your help.
 
You'll have to provide a little more detail in order for us to be able to
help.

First, are you talking about a "true" module (one that you get to through
the Modules tab), as opposed to a module associated with a form or report?

Assuming it's a true module, how did you declare the function (i.e.:
hopefully you don't have the keyword Private in front of the Function
declaration), and how are you trying to call it?
 
Functions called from queries need to be public functions saved to a module.
Could you post your code and the SQL from your query?

Barry
 
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String, keyvalue) As Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset, dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname, rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT Hours End])

Thanks,
Dwayne
 
How are you calling the query? Is it through code, or are you simply
double-clicking on the query to open it? If you're opening it through code,
what's that code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dwayne Struble said:
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String, keyvalue) As Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset, dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname, rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT Hours End])

Thanks,
Dwayne


Barry Gilbert said:
Functions called from queries need to be public functions saved to a
module.
Could you post your code and the SQL from your query?

Barry
 
Doug,

Since I am still setting up the database, I am running it after I save by
going from design view to datasheet view. Also I get the error when double
clicking on it.

Thanks,
Dwayne

Douglas J. Steele said:
How are you calling the query? Is it through code, or are you simply
double-clicking on the query to open it? If you're opening it through code,
what's that code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dwayne Struble said:
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String, keyvalue) As Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset, dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname, rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT Hours End])

Thanks,
Dwayne


Barry Gilbert said:
Functions called from queries need to be public functions saved to a
module.
Could you post your code and the SQL from your query?

Barry

:

I am a new Access user, and am using access 97. I am working on
setting up a
callout list where the order is determined by overtime hours worked. I
set
upa query that adds the hours at start of pay period with the hours
worked
and gets total then sorts it. I then need it to show the updated place
in
the order. I found a funtion that does that in another post here, but
when I
put the funtion in a module and called it in the query, I get an error
stating undefined funtion. Thanks for your help.
 
You didn't answer one of my earlier questions: are you talking about a
"true" module (one that you get to through
the Modules tab), as opposed to a module associated with a form or report?

I assume you've checked to ensure that you haven't mistyped the name of the
function in your query.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dwayne Struble said:
Doug,

Since I am still setting up the database, I am running it after I save by
going from design view to datasheet view. Also I get the error when
double
clicking on it.

Thanks,
Dwayne

Douglas J. Steele said:
How are you calling the query? Is it through code, or are you simply
double-clicking on the query to open it? If you're opening it through
code,
what's that code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String, keyvalue) As
Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset, dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname,
rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT Hours End])

Thanks,
Dwayne


:

Functions called from queries need to be public functions saved to a
module.
Could you post your code and the SQL from your query?

Barry

:

I am a new Access user, and am using access 97. I am working on
setting up a
callout list where the order is determined by overtime hours worked.
I
set
upa query that adds the hours at start of pay period with the hours
worked
and gets total then sorts it. I then need it to show the updated
place
in
the order. I found a funtion that does that in another post here,
but
when I
put the funtion in a module and called it in the query, I get an
error
stating undefined funtion. Thanks for your help.
 
Doug,

Sorry, yes I made it a module in the module area. Yes I did verify my
spelling was consistant in both areas.

Dwayne

Douglas J. Steele said:
You didn't answer one of my earlier questions: are you talking about a
"true" module (one that you get to through
the Modules tab), as opposed to a module associated with a form or report?

I assume you've checked to ensure that you haven't mistyped the name of the
function in your query.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dwayne Struble said:
Doug,

Since I am still setting up the database, I am running it after I save by
going from design view to datasheet view. Also I get the error when
double
clicking on it.

Thanks,
Dwayne

Douglas J. Steele said:
How are you calling the query? Is it through code, or are you simply
double-clicking on the query to open it? If you're opening it through
code,
what's that code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String, keyvalue) As
Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset, dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname,
rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT Hours End])

Thanks,
Dwayne


:

Functions called from queries need to be public functions saved to a
module.
Could you post your code and the SQL from your query?

Barry

:

I am a new Access user, and am using access 97. I am working on
setting up a
callout list where the order is determined by overtime hours worked.
I
set
upa query that adds the hours at start of pay period with the hours
worked
and gets total then sorts it. I then need it to show the updated
place
in
the order. I found a funtion that does that in another post here,
but
when I
put the funtion in a module and called it in the query, I get an
error
stating undefined funtion. Thanks for your help.
 
What happens if you go to the Immediate window (Ctrl-G), type

?Serialize("OPS Communicators","OT Hours End",xxx)

(replacing xxx with a legitimate value) and hit Enter?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dwayne Struble said:
Doug,

Sorry, yes I made it a module in the module area. Yes I did verify my
spelling was consistant in both areas.

Dwayne

Douglas J. Steele said:
You didn't answer one of my earlier questions: are you talking about a
"true" module (one that you get to through
the Modules tab), as opposed to a module associated with a form or
report?

I assume you've checked to ensure that you haven't mistyped the name of
the
function in your query.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

Since I am still setting up the database, I am running it after I save
by
going from design view to datasheet view. Also I get the error when
double
clicking on it.

Thanks,
Dwayne

:

How are you calling the query? Is it through code, or are you simply
double-clicking on the query to open it? If you're opening it through
code,
what's that code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String, keyvalue)
As
Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset, dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname,
rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT Hours End])

Thanks,
Dwayne


:

Functions called from queries need to be public functions saved to
a
module.
Could you post your code and the SQL from your query?

Barry

:

I am a new Access user, and am using access 97. I am working on
setting up a
callout list where the order is determined by overtime hours
worked.
I
set
upa query that adds the hours at start of pay period with the
hours
worked
and gets total then sorts it. I then need it to show the updated
place
in
the order. I found a funtion that does that in another post
here,
but
when I
put the funtion in a module and called it in the query, I get an
error
stating undefined funtion. Thanks for your help.
 
Doug,

I get a compile error;
Expected: =

Thanks,
Dwayne


Douglas J. Steele said:
What happens if you go to the Immediate window (Ctrl-G), type

?Serialize("OPS Communicators","OT Hours End",xxx)

(replacing xxx with a legitimate value) and hit Enter?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dwayne Struble said:
Doug,

Sorry, yes I made it a module in the module area. Yes I did verify my
spelling was consistant in both areas.

Dwayne

Douglas J. Steele said:
You didn't answer one of my earlier questions: are you talking about a
"true" module (one that you get to through
the Modules tab), as opposed to a module associated with a form or
report?

I assume you've checked to ensure that you haven't mistyped the name of
the
function in your query.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

Since I am still setting up the database, I am running it after I save
by
going from design view to datasheet view. Also I get the error when
double
clicking on it.

Thanks,
Dwayne

:

How are you calling the query? Is it through code, or are you simply
double-clicking on the query to open it? If you're opening it through
code,
what's that code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String, keyvalue)
As
Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset, dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname,
rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT Hours End])

Thanks,
Dwayne


:

Functions called from queries need to be public functions saved to
a
module.
Could you post your code and the SQL from your query?

Barry

:

I am a new Access user, and am using access 97. I am working on
setting up a
callout list where the order is determined by overtime hours
worked.
I
set
upa query that adds the hours at start of pay period with the
hours
worked
and gets total then sorts it. I then need it to show the updated
place
in
the order. I found a funtion that does that in another post
here,
but
when I
put the funtion in a module and called it in the query, I get an
error
stating undefined funtion. Thanks for your help.
 
A compile error, or an execution error?

Did you include the question mark at the beginning? What did you put for
xxx?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dwayne Struble said:
Doug,

I get a compile error;
Expected: =

Thanks,
Dwayne


Douglas J. Steele said:
What happens if you go to the Immediate window (Ctrl-G), type

?Serialize("OPS Communicators","OT Hours End",xxx)

(replacing xxx with a legitimate value) and hit Enter?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

Sorry, yes I made it a module in the module area. Yes I did verify my
spelling was consistant in both areas.

Dwayne

:

You didn't answer one of my earlier questions: are you talking about a
"true" module (one that you get to through
the Modules tab), as opposed to a module associated with a form or
report?

I assume you've checked to ensure that you haven't mistyped the name
of
the
function in your query.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

Since I am still setting up the database, I am running it after I
save
by
going from design view to datasheet view. Also I get the error when
double
clicking on it.

Thanks,
Dwayne

:

How are you calling the query? Is it through code, or are you
simply
double-clicking on the query to open it? If you're opening it
through
code,
what's that code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String,
keyvalue)
As
Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset,
dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname,
rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT Hours
End])

Thanks,
Dwayne


:

Functions called from queries need to be public functions saved
to
a
module.
Could you post your code and the SQL from your query?

Barry

:

I am a new Access user, and am using access 97. I am working
on
setting up a
callout list where the order is determined by overtime hours
worked.
I
set
upa query that adds the hours at start of pay period with the
hours
worked
and gets total then sorts it. I then need it to show the
updated
place
in
the order. I found a funtion that does that in another post
here,
but
when I
put the funtion in a module and called it in the query, I get
an
error
stating undefined funtion. Thanks for your help.
 
Doug,

I tried it with and without the question mark. I got compile errors both
times. With the question mark, I got the message; External name not defined.
Without question mark I got the message; Expected: =
I used [OT Hours End] as the xxx.

Thanks,
Dwayne

Douglas J. Steele said:
A compile error, or an execution error?

Did you include the question mark at the beginning? What did you put for
xxx?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dwayne Struble said:
Doug,

I get a compile error;
Expected: =

Thanks,
Dwayne


Douglas J. Steele said:
What happens if you go to the Immediate window (Ctrl-G), type

?Serialize("OPS Communicators","OT Hours End",xxx)

(replacing xxx with a legitimate value) and hit Enter?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

Sorry, yes I made it a module in the module area. Yes I did verify my
spelling was consistant in both areas.

Dwayne

:

You didn't answer one of my earlier questions: are you talking about a
"true" module (one that you get to through
the Modules tab), as opposed to a module associated with a form or
report?

I assume you've checked to ensure that you haven't mistyped the name
of
the
function in your query.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

Since I am still setting up the database, I am running it after I
save
by
going from design view to datasheet view. Also I get the error when
double
clicking on it.

Thanks,
Dwayne

:

How are you calling the query? Is it through code, or are you
simply
double-clicking on the query to open it? If you're opening it
through
code,
what's that code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String,
keyvalue)
As
Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset,
dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname,
rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT Hours
End])

Thanks,
Dwayne


:

Functions called from queries need to be public functions saved
to
a
module.
Could you post your code and the SQL from your query?

Barry

:

I am a new Access user, and am using access 97. I am working
on
setting up a
callout list where the order is determined by overtime hours
worked.
I
set
upa query that adds the hours at start of pay period with the
hours
worked
and gets total then sorts it. I then need it to show the
updated
place
in
the order. I found a funtion that does that in another post
here,
but
when I
put the funtion in a module and called it in the query, I get
an
error
stating undefined funtion. Thanks for your help.
 
You can't use [OT Hours End] in the Immediate window: it has no way of
knowing what that is. You have to pass a value. I think that's the "External
name not defined" error. The "Expected: = " error is because you're trying
to run a function, and not giving it anyway to deal with what's being
returned. If you want to try without wanting the value that's returned, you
need to use the Call keyword:

Call Serialize("OPS Communicators","OT Hours End",xxx)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dwayne Struble said:
Doug,

I tried it with and without the question mark. I got compile errors both
times. With the question mark, I got the message; External name not
defined.
Without question mark I got the message; Expected: =
I used [OT Hours End] as the xxx.

Thanks,
Dwayne

Douglas J. Steele said:
A compile error, or an execution error?

Did you include the question mark at the beginning? What did you put for
xxx?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

I get a compile error;
Expected: =

Thanks,
Dwayne


:

What happens if you go to the Immediate window (Ctrl-G), type

?Serialize("OPS Communicators","OT Hours End",xxx)

(replacing xxx with a legitimate value) and hit Enter?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

Sorry, yes I made it a module in the module area. Yes I did verify
my
spelling was consistant in both areas.

Dwayne

:

You didn't answer one of my earlier questions: are you talking
about a
"true" module (one that you get to through
the Modules tab), as opposed to a module associated with a form or
report?

I assume you've checked to ensure that you haven't mistyped the
name
of
the
function in your query.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

Since I am still setting up the database, I am running it after
I
save
by
going from design view to datasheet view. Also I get the error
when
double
clicking on it.

Thanks,
Dwayne

:

How are you calling the query? Is it through code, or are you
simply
double-clicking on the query to open it? If you're opening it
through
code,
what's that code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


in
message
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String,
keyvalue)
As
Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset,
dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname,
rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT Hours
End])

Thanks,
Dwayne


:

Functions called from queries need to be public functions
saved
to
a
module.
Could you post your code and the SQL from your query?

Barry

:

I am a new Access user, and am using access 97. I am
working
on
setting up a
callout list where the order is determined by overtime
hours
worked.
I
set
upa query that adds the hours at start of pay period with
the
hours
worked
and gets total then sorts it. I then need it to show the
updated
place
in
the order. I found a funtion that does that in another
post
here,
but
when I
put the funtion in a module and called it in the query, I
get
an
error
stating undefined funtion. Thanks for your help.
 
Doug,

I tried it using 1 or 2 as xxx and also using the call command. I now get
a compile error with this message; Expected variable or Procedure, not
Module. I also tried just using the absoluteposition function in an
expression within query and I get the error, unknown function
absoluteposition, and that is one that is in Access.

Thanks,
Dwayne

Douglas J. Steele said:
You can't use [OT Hours End] in the Immediate window: it has no way of
knowing what that is. You have to pass a value. I think that's the "External
name not defined" error. The "Expected: = " error is because you're trying
to run a function, and not giving it anyway to deal with what's being
returned. If you want to try without wanting the value that's returned, you
need to use the Call keyword:

Call Serialize("OPS Communicators","OT Hours End",xxx)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dwayne Struble said:
Doug,

I tried it with and without the question mark. I got compile errors both
times. With the question mark, I got the message; External name not
defined.
Without question mark I got the message; Expected: =
I used [OT Hours End] as the xxx.

Thanks,
Dwayne

Douglas J. Steele said:
A compile error, or an execution error?

Did you include the question mark at the beginning? What did you put for
xxx?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

I get a compile error;
Expected: =

Thanks,
Dwayne


:

What happens if you go to the Immediate window (Ctrl-G), type

?Serialize("OPS Communicators","OT Hours End",xxx)

(replacing xxx with a legitimate value) and hit Enter?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

Sorry, yes I made it a module in the module area. Yes I did verify
my
spelling was consistant in both areas.

Dwayne

:

You didn't answer one of my earlier questions: are you talking
about a
"true" module (one that you get to through
the Modules tab), as opposed to a module associated with a form or
report?

I assume you've checked to ensure that you haven't mistyped the
name
of
the
function in your query.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

Since I am still setting up the database, I am running it after
I
save
by
going from design view to datasheet view. Also I get the error
when
double
clicking on it.

Thanks,
Dwayne

:

How are you calling the query? Is it through code, or are you
simply
double-clicking on the query to open it? If you're opening it
through
code,
what's that code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


in
message
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String,
keyvalue)
As
Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset,
dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname,
rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT Hours
End])

Thanks,
Dwayne


:

Functions called from queries need to be public functions
saved
to
a
module.
Could you post your code and the SQL from your query?

Barry

:

I am a new Access user, and am using access 97. I am
working
on
setting up a
callout list where the order is determined by overtime
hours
worked.
I
set
upa query that adds the hours at start of pay period with
the
hours
worked
and gets total then sorts it. I then need it to show the
updated
place
in
the order. I found a funtion that does that in another
post
here,
but
when I
put the funtion in a module and called it in the query, I
get
an
error
stating undefined funtion. Thanks for your help.
 
Sorry, I'm running out of ideas. As a test, I just copied the function you
posted into an existing Access 97 database, and had no problem using it in a
query.

Try putting a breakpoint into the function (you do this by clicking in the
border to the left of a line of code in the editor. This should put a circle
in the border, and highlight the entire row). Then, try executing the same
command in the immediate window. You should be taken into the function.
Single-step through the code, using the F8 key. What line of code is raising
the error?

I don't understand what you mean by "using the absoluteposition function in
an expression within query". The AbsolutePosition property only applies to
recordsets: you can't put it into a query.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dwayne Struble said:
Doug,

I tried it using 1 or 2 as xxx and also using the call command. I now
get
a compile error with this message; Expected variable or Procedure, not
Module. I also tried just using the absoluteposition function in an
expression within query and I get the error, unknown function
absoluteposition, and that is one that is in Access.

Thanks,
Dwayne

Douglas J. Steele said:
You can't use [OT Hours End] in the Immediate window: it has no way of
knowing what that is. You have to pass a value. I think that's the
"External
name not defined" error. The "Expected: = " error is because you're
trying
to run a function, and not giving it anyway to deal with what's being
returned. If you want to try without wanting the value that's returned,
you
need to use the Call keyword:

Call Serialize("OPS Communicators","OT Hours End",xxx)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

I tried it with and without the question mark. I got compile errors
both
times. With the question mark, I got the message; External name not
defined.
Without question mark I got the message; Expected: =
I used [OT Hours End] as the xxx.

Thanks,
Dwayne

:

A compile error, or an execution error?

Did you include the question mark at the beginning? What did you put
for
xxx?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

I get a compile error;
Expected: =

Thanks,
Dwayne


:

What happens if you go to the Immediate window (Ctrl-G), type

?Serialize("OPS Communicators","OT Hours End",xxx)

(replacing xxx with a legitimate value) and hit Enter?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
Doug,

Sorry, yes I made it a module in the module area. Yes I did
verify
my
spelling was consistant in both areas.

Dwayne

:

You didn't answer one of my earlier questions: are you talking
about a
"true" module (one that you get to through
the Modules tab), as opposed to a module associated with a form
or
report?

I assume you've checked to ensure that you haven't mistyped the
name
of
the
function in your query.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


in
message
Doug,

Since I am still setting up the database, I am running it
after
I
save
by
going from design view to datasheet view. Also I get the
error
when
double
clicking on it.

Thanks,
Dwayne

:

How are you calling the query? Is it through code, or are you
simply
double-clicking on the query to open it? If you're opening it
through
code,
what's that code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


"Dwayne Struble" <[email protected]>
wrote
in
message
Here is the module I am trying to use.

Function Serialize(qryname As String, keyname As String,
keyvalue)
As
Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset,
dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname,
rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Here is how I am trying to call it in a query.


Expr1: Serialize("OPS Communicators","OT Hours End",[OT
Hours
End])

Thanks,
Dwayne


:

Functions called from queries need to be public functions
saved
to
a
module.
Could you post your code and the SQL from your query?

Barry

:

I am a new Access user, and am using access 97. I am
working
on
setting up a
callout list where the order is determined by overtime
hours
worked.
I
set
upa query that adds the hours at start of pay period
with
the
hours
worked
and gets total then sorts it. I then need it to show
the
updated
place
in
the order. I found a funtion that does that in another
post
here,
but
when I
put the funtion in a module and called it in the query,
I
get
an
error
stating undefined funtion. Thanks for your help.
 

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

Similar Threads

DLookup Problem 10
Rollup funtion in Access 1
Trouble using the Replace Function 5
Time Tracking & Reports 1
Sorting Dates 14
Access Modules empty 0
How should I do this........ 5
Help with my tables 9

Back
Top