M
Mark
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
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