Function to return data contained in a table 
Author Message
 Function to return data contained in a table

This is a multi-part message in MIME format.

------=_NextPart_000_01BC4820.E56535E0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

I am trying to write a function to return the customer name from the
customer table. I am passing the customer key to the function contained in
the module, and would like to return the customer name. Since this will be
used many times in my program, I think it is best to create a snapshot in
read only mode and open the table once when the screen is open, and close
it only after several records are entered.

I would appreciate any help someone could provide. Thank you very much!
--
Please respond directly to my Email account at the following address:


Thank you in advance!
John

------=_NextPart_000_01BC4820.E56535E0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<html><head></head><BODY bgcolor=3D"#FFFFFF"><p><font size=3D2 =
color=3D"#000000" face=3D"Arial">I am trying to write a function to =
return the customer name from the customer table. I am passing the =
customer key to the function contained in the module, and would like to =
return the customer name. Since this will be used many times in my =
program, I think it is best to create a snapshot in read only mode and =
open the table once when the screen is open, and close it only after =
several records are entered.<br><br>I would appreciate any help someone =
could provide. Thank you very much!<br>-- <br>Please respond directly to =
my Email account at the following address:<br><br><font =

color=3D"#000000"><br><br>Thank you in advance!<br>John<br><br><br></p>
</font></font></font></body></html>
------=_NextPart_000_01BC4820.E56535E0--



Thu, 30 Sep 1999 03:00:00 GMT  
 Function to return data contained in a table

You are on the right path with a read only, but do not use a snapshot. Use
the seek method on a table, however use the Read Only constant.
Function Foo (lngId as long) as string
dim db as database, rst as recordset

set db=currentdb
set rst=db.openrecordset("tblCustomer",dbReadOnly)
rst.index = "PrimaryKey"
rst.seek "=", lngID

Foo=rst!CustomerName

End Function

That should do the trick.
(This is for Access 95/97) Let me know if you are using Access 2.
--
Stephen Forte
President, NYC Access VB User Group

http://www.auroradev.com/



I am trying to write a function to return the customer name from the
customer table. I am passing the customer key to the function contained in
the module, and would like to return the customer name. Since this will be
used many times in my program, I think it is best to create a snapshot in
read only mode and open the table once when the screen is open, and close
it only after several records are entered.

I would appreciate any help someone could provide. Thank you very much!
--
Please respond directly to my Email account at the following address:


Thank you in advance!
John

----------



Thu, 30 Sep 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Occasionally having empty recordsets returned that should contain data

2. normalising table with a fields containing CSV data

3. Normalizing non-normal tables already containing data;OR changing columns into rows

4. How to find out if table contains data?

5. Executing Function using String Containing Function Name

6. Web Service returning a data table

7. MID function returning incorrect data

8. problem using component with asp page -- result of function not returned, instead original value returned

9. string returned from dll contains NUL

10. api returned long contains and address?

11. Variant containing a Byte Array returned from C++

12. ADO don't get output param or return value when stored procedure contains update

 

 
Powered by phpBB® Forum Software