Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Module

Status
Not open for further replies.

HMJ

Technical User
Nov 29, 2002
58
0
0
US
Hello All,

I am fairly new to this, and am trying to use a module to create an item by joining two fields. It is simple, but I can't seem to figure out how to make it work.

We have a field called [lastname] and another called [firstname] - original ain't we? When we run reports, etc, we allways setup the query with name:=[lastanme]&", "&[firstname]. Who wants to type this evertime they do a query, so I am trying to setup a module with a function built to do this for us so all we have to do is enter Name in the query field.

Can someone help me out here?

Thank You.
 
There is no point.
You would have to feed the functon with enough data for it to work out which record it was working with and which fields to join.
You might as well stay as you are.

 
Lupins is correct but, if the relevant field names are always the same "FirstName" & "LastName", Then maybe only the table name & PrimaryKey would be required?

Function Both(strTable As String, intID AS iNTEGER) As String
Dim strFirst A string, StrLast As string

strFirst = DLookUp("txtFirstName",strTable,"pkID =" & intID)
strLast = DLookUp("txtLastName",strTable,"pkID =" & intID)

Both = strLast & ", " & strfirst

End function

Name: Both(tblCompany,pkCompanyID)

again, as Lupins said, if it's "space" you want to save, what's the point, if errors, then maybe worth the while?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top