Simple IF THEN to Populate a Form Field

S

schlake21

I've got a form with a field pulling a client list with Row Source:
SELECT tblClients.ClientName, tblClients.ClientID FROM tblClients ORDER BY
tblClients.ClientName;

And a field pulling the Activity currently being tracked with Row Source:
SELECT tblDocketingActivity.ActivityName FROM tblDocketingActivity;

I am praying there is a simple way to make this work, despite the previous
posts that I've sifted through suggesting Event Procedures and Re-Querying:

IF ClientName = "Non-Client Work," THEN Activity = "Non-Client Work"
("Non-Client Work" is an option in both lists)

The logic of this seems really simple, but I've yet to find a simple answer
posted anywhere...

Thanks!
Gabe

Warning: SQL kinda makes my brain hurt.
 
K

KARL DEWEY

("Non-Client Work" is an option in both lists)

What lists?

Syntax in query design view ----
Activity: IF([ClientName] = "Non-Client Work", "Non-Client Work",
"Something else")
 
S

schlake21

They're listed in the Row Sources below: Each field is pulling from a table
that lists either Clients or Activities; "Non-Client Work" is an option that
can be selected from each of these lists (tables).

Thanks--

KARL DEWEY said:
What lists?

Syntax in query design view ----
Activity: IF([ClientName] = "Non-Client Work", "Non-Client Work",
"Something else")

--
KARL DEWEY
Build a little - Test a little


schlake21 said:
I've got a form with a field pulling a client list with Row Source:
SELECT tblClients.ClientName, tblClients.ClientID FROM tblClients ORDER BY
tblClients.ClientName;

And a field pulling the Activity currently being tracked with Row Source:
SELECT tblDocketingActivity.ActivityName FROM tblDocketingActivity;

I am praying there is a simple way to make this work, despite the previous
posts that I've sifted through suggesting Event Procedures and Re-Querying:

IF ClientName = "Non-Client Work," THEN Activity = "Non-Client Work"
("Non-Client Work" is an option in both lists)

The logic of this seems really simple, but I've yet to find a simple answer
posted anywhere...

Thanks!
Gabe

Warning: SQL kinda makes my brain hurt.
 
K

KARL DEWEY

Try this --
SELECT tblClients.ClientName, tblClients.ClientID, IF([ClientName] =
"Non-Client Work", "Non-Client Work", tblDocketingActivity.ActivityName) AS
Client_Activity
FROM tblClients LEFT JOIN tblDocketingActivity ON tblClients.Activity =
tblDocketingActivity.ActivityName
ORDER BY tblClients.ClientName;

If it does not work then post your table structure, field names and
datatype, and sample data from each table.

--
KARL DEWEY
Build a little - Test a little


schlake21 said:
They're listed in the Row Sources below: Each field is pulling from a table
that lists either Clients or Activities; "Non-Client Work" is an option that
can be selected from each of these lists (tables).

Thanks--

KARL DEWEY said:
("Non-Client Work" is an option in both lists)

What lists?

Syntax in query design view ----
Activity: IF([ClientName] = "Non-Client Work", "Non-Client Work",
"Something else")

--
KARL DEWEY
Build a little - Test a little


schlake21 said:
I've got a form with a field pulling a client list with Row Source:
SELECT tblClients.ClientName, tblClients.ClientID FROM tblClients ORDER BY
tblClients.ClientName;

And a field pulling the Activity currently being tracked with Row Source:
SELECT tblDocketingActivity.ActivityName FROM tblDocketingActivity;

I am praying there is a simple way to make this work, despite the previous
posts that I've sifted through suggesting Event Procedures and Re-Querying:

IF ClientName = "Non-Client Work," THEN Activity = "Non-Client Work"
("Non-Client Work" is an option in both lists)

The logic of this seems really simple, but I've yet to find a simple answer
posted anywhere...

Thanks!
Gabe

Warning: SQL kinda makes my brain hurt.
 
S

schlake21

No go...

Here's what I've got:

Form: frmTimeTrackingMaster
Form Record Source: tblTimeTrackingMaster
Form Field 1: Combo Box (Named ClientLookup) with Control Source ClientID
--> Row Source: SELECT tblClients.ClientName, tblClients.ClientID FROM
tblClients ORDER BY tblClients.ClientName;

Form Field 2: Combo Box (Named DocketingActivityLookup) with Control Source
Activity
--> Row Source: SELECT tblDocketingActivity.ActivityName FROM
tblDocketingActivity;

tblClients: ClientID ClientName
--------- ------------------
80000 Non-Client Work
80001 Client Number 1
80002 Client Number 2

tblDocketingActivity: ActivityName
---------------
Client Project
Incoming Mail
Non-Client Work

Sooooo... All I'm looking for is this: If the ClientLookup is set to
"Non-Client Work", then set DocketingActivityLookup to "Non-Client Work."

Thanks for your help!
Gabe


KARL DEWEY said:
Try this --
SELECT tblClients.ClientName, tblClients.ClientID, IF([ClientName] =
"Non-Client Work", "Non-Client Work", tblDocketingActivity.ActivityName) AS
Client_Activity
FROM tblClients LEFT JOIN tblDocketingActivity ON tblClients.Activity =
tblDocketingActivity.ActivityName
ORDER BY tblClients.ClientName;

If it does not work then post your table structure, field names and
datatype, and sample data from each table.

--
KARL DEWEY
Build a little - Test a little


schlake21 said:
They're listed in the Row Sources below: Each field is pulling from a table
that lists either Clients or Activities; "Non-Client Work" is an option that
can be selected from each of these lists (tables).

Thanks--

KARL DEWEY said:
("Non-Client Work" is an option in both lists)

What lists?

Syntax in query design view ----
Activity: IF([ClientName] = "Non-Client Work", "Non-Client Work",
"Something else")

--
KARL DEWEY
Build a little - Test a little


:

I've got a form with a field pulling a client list with Row Source:
SELECT tblClients.ClientName, tblClients.ClientID FROM tblClients ORDER BY
tblClients.ClientName;

And a field pulling the Activity currently being tracked with Row Source:
SELECT tblDocketingActivity.ActivityName FROM tblDocketingActivity;

I am praying there is a simple way to make this work, despite the previous
posts that I've sifted through suggesting Event Procedures and Re-Querying:

IF ClientName = "Non-Client Work," THEN Activity = "Non-Client Work"
("Non-Client Work" is an option in both lists)

The logic of this seems really simple, but I've yet to find a simple answer
posted anywhere...

Thanks!
Gabe

Warning: SQL kinda makes my brain hurt.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top