Talk About Network

Google





Software > Access General > Q: returning "f...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 97466 of 98261
Post > Topic >>

Q: returning "field expression" from recordset object?

by =?Utf-8?B?TWFyaw==?= <Mark@[EMAIL PROTECTED] > Dec 1, 2008 at 05:30 PM

Hi all,

Say I have a table called NAMELIST with two fields, NAME1 and NAME2.
There's 
only one record n the table, and NAME1=Bill, NAME2=Gates

I want to write a function where you enter the table name and the
expression 
of the fields you want. So, for example, you could enter NAME1 or NAME2 or

(and this is where I'm having trouble) NAME1 & " " & NAME2.

Getting a single field is straightforward. I have some dummy code below
that 
works for a single field. But  I have no idea how to get it to return
NAME1 & 
" " & NAME2, ie "Bill Gates"

Any help greatly appreciated!
-Mark

Function GetVal(str As String, strexp As String) As String
Dim db As Database
Dim rs As Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset(str)
rs.MoveFirst

'This works if strexp is a single field.
'but how do I return "Name1 & Name2"?
GetVal = rs(strexp)
End Function
 




 3 Posts in Topic:
Q: returning "field expression" from recordset object?
=?Utf-8?B?TWFyaw==?= <  2008-12-01 17:30:01 
Re: returning "field expression" from recordset object?
"Allen Browne"   2008-12-02 10:46:03 
Re: returning "field expression" from recordset object?
=?Utf-8?B?TWFyaw==?= <  2008-12-02 09:44:15 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Thu Jan 8 7:54:57 PST 2009.