Kamis, 28 Juli 2016

Re: [MS_AccessPros] Replace field if another exists.

 

Art-

Yup.  But it sounds like you need something like:

IIf(IsNull([Forms]![Myform]![cmbPersonID]), [FirstName] & " " & [LastName], DLookup("PersonName", "OtherTable", "PersonID = " & [Forms]![Myform]![cmbPersonID]))

John Viescas, author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Access Applications

On Jul 28, 2016, at 18:23, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

Here is example of what you are talking about I have in another application:

SELECT [Learning Center Non Client Activities].NonClientActivityID, [Learning Center Non Client Activities].LearningCenterID, [Learning Center Non Client Activities].ActivityDate, IIf(IsNull([ProgramName]),[LastName] & ", " & [FirstName],[ProgramName]) AS [Non-ClientName], [Learning Center Non Client Activities].Note, [Lookup Learning Center Client Activity Type].ClientActivityDetailName, [Learning Center Non Client Activities].ActivityTypeID
FROM [Learning Center Non Client Activities] INNER JOIN [Lookup Learning Center Client Activity Type] ON [Learning Center Non Client Activities].ActivityTypeID=[Lookup Learning Center Client Activity Type].ClientActivityDetailID;

 IIf(IsNull([ProgramName]),[LastName] & ", " & [FirstName],[ProgramName]) AS [Non-ClientName

But in my new case, Instead of ProgramName I have PersonID, BUt I need to use the DLOOKUP to pull the person name out of tblPerson based on the PersonID selected.

With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Anyone who claimed that old age had brought them patience was either lying or senile."  







From: "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: MS_Access_Professionals@yahoogroups.com
Sent: Thursday, July 28, 2016 2:26 PM
Subject: Re: [MS_AccessPros] Replace field if another exists.

 
Art-

Sounds like you need an IIf function that tests the selection in the combo box and returns either the concatenated name or a DLookup to the other table.  Without more info, I can't give you specific code.

John Viescas, author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Access Applications

On Jul 28, 2016, at 16:11, dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

I have a query in which I need to display either the concatenated fullname or a name based on a ID in another table.

Select [FirstName] & " " & [LastName] as FullName, (or associated name from tblPerson if PersonID is selected, CitationID, Code, CitiationDate
FROM tblCitation

I would need to pull the [FirstName] & " " & [LastName] from tblPerson If the user selects a PersonID from the dropdown.

Clear as mud  know

Thank you,
Art Lorenzini
Sioux Falls, SD


__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)

Save time and get your email on the go with the Yahoo Mail app
Get the beautifully designed, lighting fast, and easy-to-use Yahoo Mail today. Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar