Code for related tables

D

Dagre

I have two tables, one called tblTasks, which contains task information to be
assigned using Outlook. The other is called tblEmployees, and includes info
such as Name, Position, Department and Email.
tblTasks is related to tblEmployees through Employee Name. I have added code
to frmTasks which creates the task in Outlook, and Assigns it to another
employee. Currently, I have got it looking in a text box which contains the
email address to send the task to.

I have a field in tblTasks called Name, which has the name of the employee
which the task is going to be assigned to. I would prefer to be able to
select a name from the list, and it looks up the email address from
tblEmployees, and assigns the task to that person.

Any ideas?
 
J

Jeff Boyce

Dagre

I'm not quite clear on the relationships among your data.

If a single employee only handles a task (i.e., you don't assign two folks
to handle the task, not simultaneously nor consecutively), and if you don't
need to 'normalize' your tasks (for example, each task is unique -- never
the same task more than one time), then your table structure seems
appropriate.

However, if either of the 'contrary' conditions mentioned above can happen,
you might need to have one table for employees, one table for tasks, and a
third table to handle "assignments".

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
D

Dagre

Hmm, I don't think I explained too well.

I have two tables, tblTasks and tblEmployees, both related by "Employee
Name" field.

I have been using a button on frmTasks, which let me assign a task to an
employee using an email address I physically typed into the code (I am only
learning and testing atm). I then tried to link it with a field, so that if I
type an email address into a field, it sends the task.

However, I don't actually want to do this in the final copy. The Name field
is a combo box with names of employees in it, and I ideally want to be able
to click an employee name, and it sends to the related email address, which
it should be looking up from tblEmployees.

Did that make any sense? :S
 
J

Jeff Boyce

First off, using [EmployeeName] as a unique identifier (you are using it to
connect the tables) is risky. What will you do if you hire two "John Doe"s?

It sounds like you want the combobox from which you pick an employee to
automatically send an email. If so, check into the combobox's AfterUpdate
event, and the SendObject() function.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
D

Dagre

If we had two employees with the same name, I think we would probably do
something like add a middle initial for one of them, or possible add the
department in brackets, something like that to make it unique.

I don't want to send the assignment until I press the Assign Task button.
This is the existing code associated with the Assign Task button:

Private Sub btnSaveToTasks_Click()
Dim outTask As Outlook.TaskItem
Dim outApp As Outlook.Application
Set outApp = New Outlook.Application
Set outTask = outApp.CreateItem(olTaskItem)
outTask.DueDate = Me.Date
outTask.ReminderTime = Me.ReminderMinutes
outTask.Body = Me.Notes
outTask.Recipients.Add Me.EmployeeName
outTask.Assign
outTask.Send
Set outTask = Nothing
Set outApp = Nothing
End Sub

outTask.Recipients.Add is currently pointing to Employee Name, but in order
to send I actually have to type an email address. I need to find a code that
allows me to select a name, and it find the email address related to that
name, if that makes any sense.



Jeff Boyce said:
First off, using [EmployeeName] as a unique identifier (you are using it to
connect the tables) is risky. What will you do if you hire two "John Doe"s?

It sounds like you want the combobox from which you pick an employee to
automatically send an email. If so, check into the combobox's AfterUpdate
event, and the SendObject() function.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Dagre said:
Hmm, I don't think I explained too well.

I have two tables, tblTasks and tblEmployees, both related by "Employee
Name" field.

I have been using a button on frmTasks, which let me assign a task to an
employee using an email address I physically typed into the code (I am
only
learning and testing atm). I then tried to link it with a field, so that
if I
type an email address into a field, it sends the task.

However, I don't actually want to do this in the final copy. The Name
field
is a combo box with names of employees in it, and I ideally want to be
able
to click an employee name, and it sends to the related email address,
which
it should be looking up from tblEmployees.

Did that make any sense? :S
 
J

Jeff Boyce

Doesn't your Employee table include an email address?

One solution might be to use the DLookup() function to find the email
address that belongs to the Employee.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Dagre said:
If we had two employees with the same name, I think we would probably do
something like add a middle initial for one of them, or possible add the
department in brackets, something like that to make it unique.

I don't want to send the assignment until I press the Assign Task button.
This is the existing code associated with the Assign Task button:

Private Sub btnSaveToTasks_Click()
Dim outTask As Outlook.TaskItem
Dim outApp As Outlook.Application
Set outApp = New Outlook.Application
Set outTask = outApp.CreateItem(olTaskItem)
outTask.DueDate = Me.Date
outTask.ReminderTime = Me.ReminderMinutes
outTask.Body = Me.Notes
outTask.Recipients.Add Me.EmployeeName
outTask.Assign
outTask.Send
Set outTask = Nothing
Set outApp = Nothing
End Sub

outTask.Recipients.Add is currently pointing to Employee Name, but in
order
to send I actually have to type an email address. I need to find a code
that
allows me to select a name, and it find the email address related to that
name, if that makes any sense.



Jeff Boyce said:
First off, using [EmployeeName] as a unique identifier (you are using it
to
connect the tables) is risky. What will you do if you hire two "John
Doe"s?

It sounds like you want the combobox from which you pick an employee to
automatically send an email. If so, check into the combobox's
AfterUpdate
event, and the SendObject() function.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Dagre said:
Hmm, I don't think I explained too well.

I have two tables, tblTasks and tblEmployees, both related by "Employee
Name" field.

I have been using a button on frmTasks, which let me assign a task to
an
employee using an email address I physically typed into the code (I am
only
learning and testing atm). I then tried to link it with a field, so
that
if I
type an email address into a field, it sends the task.

However, I don't actually want to do this in the final copy. The Name
field
is a combo box with names of employees in it, and I ideally want to be
able
to click an employee name, and it sends to the related email address,
which
it should be looking up from tblEmployees.

Did that make any sense? :S



:

Dagre

I'm not quite clear on the relationships among your data.

If a single employee only handles a task (i.e., you don't assign two
folks
to handle the task, not simultaneously nor consecutively), and if you
don't
need to 'normalize' your tasks (for example, each task is unique --
never
the same task more than one time), then your table structure seems
appropriate.

However, if either of the 'contrary' conditions mentioned above can
happen,
you might need to have one table for employees, one table for tasks,
and
a
third table to handle "assignments".

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

I have two tables, one called tblTasks, which contains task
information
to
be
assigned using Outlook. The other is called tblEmployees, and
includes
info
such as Name, Position, Department and Email.
tblTasks is related to tblEmployees through Employee Name. I have
added
code
to frmTasks which creates the task in Outlook, and Assigns it to
another
employee. Currently, I have got it looking in a text box which
contains
the
email address to send the task to.

I have a field in tblTasks called Name, which has the name of the
employee
which the task is going to be assigned to. I would prefer to be able
to
select a name from the list, and it looks up the email address from
tblEmployees, and assigns the task to that person.

Any ideas?
 
D

Dagre

Sorry for the delay in replying...

I don't actually know how to do this. How would I go about using dlookup?

Jeff Boyce said:
Doesn't your Employee table include an email address?

One solution might be to use the DLookup() function to find the email
address that belongs to the Employee.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Dagre said:
If we had two employees with the same name, I think we would probably do
something like add a middle initial for one of them, or possible add the
department in brackets, something like that to make it unique.

I don't want to send the assignment until I press the Assign Task button.
This is the existing code associated with the Assign Task button:

Private Sub btnSaveToTasks_Click()
Dim outTask As Outlook.TaskItem
Dim outApp As Outlook.Application
Set outApp = New Outlook.Application
Set outTask = outApp.CreateItem(olTaskItem)
outTask.DueDate = Me.Date
outTask.ReminderTime = Me.ReminderMinutes
outTask.Body = Me.Notes
outTask.Recipients.Add Me.EmployeeName
outTask.Assign
outTask.Send
Set outTask = Nothing
Set outApp = Nothing
End Sub

outTask.Recipients.Add is currently pointing to Employee Name, but in
order
to send I actually have to type an email address. I need to find a code
that
allows me to select a name, and it find the email address related to that
name, if that makes any sense.



Jeff Boyce said:
First off, using [EmployeeName] as a unique identifier (you are using it
to
connect the tables) is risky. What will you do if you hire two "John
Doe"s?

It sounds like you want the combobox from which you pick an employee to
automatically send an email. If so, check into the combobox's
AfterUpdate
event, and the SendObject() function.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Hmm, I don't think I explained too well.

I have two tables, tblTasks and tblEmployees, both related by "Employee
Name" field.

I have been using a button on frmTasks, which let me assign a task to
an
employee using an email address I physically typed into the code (I am
only
learning and testing atm). I then tried to link it with a field, so
that
if I
type an email address into a field, it sends the task.

However, I don't actually want to do this in the final copy. The Name
field
is a combo box with names of employees in it, and I ideally want to be
able
to click an employee name, and it sends to the related email address,
which
it should be looking up from tblEmployees.

Did that make any sense? :S



:

Dagre

I'm not quite clear on the relationships among your data.

If a single employee only handles a task (i.e., you don't assign two
folks
to handle the task, not simultaneously nor consecutively), and if you
don't
need to 'normalize' your tasks (for example, each task is unique --
never
the same task more than one time), then your table structure seems
appropriate.

However, if either of the 'contrary' conditions mentioned above can
happen,
you might need to have one table for employees, one table for tasks,
and
a
third table to handle "assignments".

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

I have two tables, one called tblTasks, which contains task
information
to
be
assigned using Outlook. The other is called tblEmployees, and
includes
info
such as Name, Position, Department and Email.
tblTasks is related to tblEmployees through Employee Name. I have
added
code
to frmTasks which creates the task in Outlook, and Assigns it to
another
employee. Currently, I have got it looking in a text box which
contains
the
email address to send the task to.

I have a field in tblTasks called Name, which has the name of the
employee
which the task is going to be assigned to. I would prefer to be able
to
select a name from the list, and it looks up the email address from
tblEmployees, and assigns the task to that person.

Any ideas?
 
D

Dagre

Sorry for the delay in replying...

I don't actually know how to do this. How would I go about using dlookup?

Jeff Boyce said:
Doesn't your Employee table include an email address?

One solution might be to use the DLookup() function to find the email
address that belongs to the Employee.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Dagre said:
If we had two employees with the same name, I think we would probably do
something like add a middle initial for one of them, or possible add the
department in brackets, something like that to make it unique.

I don't want to send the assignment until I press the Assign Task button.
This is the existing code associated with the Assign Task button:

Private Sub btnSaveToTasks_Click()
Dim outTask As Outlook.TaskItem
Dim outApp As Outlook.Application
Set outApp = New Outlook.Application
Set outTask = outApp.CreateItem(olTaskItem)
outTask.DueDate = Me.Date
outTask.ReminderTime = Me.ReminderMinutes
outTask.Body = Me.Notes
outTask.Recipients.Add Me.EmployeeName
outTask.Assign
outTask.Send
Set outTask = Nothing
Set outApp = Nothing
End Sub

outTask.Recipients.Add is currently pointing to Employee Name, but in
order
to send I actually have to type an email address. I need to find a code
that
allows me to select a name, and it find the email address related to that
name, if that makes any sense.



Jeff Boyce said:
First off, using [EmployeeName] as a unique identifier (you are using it
to
connect the tables) is risky. What will you do if you hire two "John
Doe"s?

It sounds like you want the combobox from which you pick an employee to
automatically send an email. If so, check into the combobox's
AfterUpdate
event, and the SendObject() function.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Hmm, I don't think I explained too well.

I have two tables, tblTasks and tblEmployees, both related by "Employee
Name" field.

I have been using a button on frmTasks, which let me assign a task to
an
employee using an email address I physically typed into the code (I am
only
learning and testing atm). I then tried to link it with a field, so
that
if I
type an email address into a field, it sends the task.

However, I don't actually want to do this in the final copy. The Name
field
is a combo box with names of employees in it, and I ideally want to be
able
to click an employee name, and it sends to the related email address,
which
it should be looking up from tblEmployees.

Did that make any sense? :S



:

Dagre

I'm not quite clear on the relationships among your data.

If a single employee only handles a task (i.e., you don't assign two
folks
to handle the task, not simultaneously nor consecutively), and if you
don't
need to 'normalize' your tasks (for example, each task is unique --
never
the same task more than one time), then your table structure seems
appropriate.

However, if either of the 'contrary' conditions mentioned above can
happen,
you might need to have one table for employees, one table for tasks,
and
a
third table to handle "assignments".

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

I have two tables, one called tblTasks, which contains task
information
to
be
assigned using Outlook. The other is called tblEmployees, and
includes
info
such as Name, Position, Department and Email.
tblTasks is related to tblEmployees through Employee Name. I have
added
code
to frmTasks which creates the task in Outlook, and Assigns it to
another
employee. Currently, I have got it looking in a text box which
contains
the
email address to send the task to.

I have a field in tblTasks called Name, which has the name of the
employee
which the task is going to be assigned to. I would prefer to be able
to
select a name from the list, and it looks up the email address from
tblEmployees, and assigns the task to that person.

Any ideas?
 
J

Jeff Boyce

Dagre

Open Access. Click on the HELP button. Type in DLookup.

The exact syntax and examples are provided.

Good luck

Regards

Jeff Boyce
Microsoft Office/Access MVP


Dagre said:
Sorry for the delay in replying...

I don't actually know how to do this. How would I go about using dlookup?

Jeff Boyce said:
Doesn't your Employee table include an email address?

One solution might be to use the DLookup() function to find the email
address that belongs to the Employee.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Dagre said:
If we had two employees with the same name, I think we would probably
do
something like add a middle initial for one of them, or possible add
the
department in brackets, something like that to make it unique.

I don't want to send the assignment until I press the Assign Task
button.
This is the existing code associated with the Assign Task button:

Private Sub btnSaveToTasks_Click()
Dim outTask As Outlook.TaskItem
Dim outApp As Outlook.Application
Set outApp = New Outlook.Application
Set outTask = outApp.CreateItem(olTaskItem)
outTask.DueDate = Me.Date
outTask.ReminderTime = Me.ReminderMinutes
outTask.Body = Me.Notes
outTask.Recipients.Add Me.EmployeeName
outTask.Assign
outTask.Send
Set outTask = Nothing
Set outApp = Nothing
End Sub

outTask.Recipients.Add is currently pointing to Employee Name, but in
order
to send I actually have to type an email address. I need to find a code
that
allows me to select a name, and it find the email address related to
that
name, if that makes any sense.



:

First off, using [EmployeeName] as a unique identifier (you are using
it
to
connect the tables) is risky. What will you do if you hire two "John
Doe"s?

It sounds like you want the combobox from which you pick an employee
to
automatically send an email. If so, check into the combobox's
AfterUpdate
event, and the SendObject() function.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Hmm, I don't think I explained too well.

I have two tables, tblTasks and tblEmployees, both related by
"Employee
Name" field.

I have been using a button on frmTasks, which let me assign a task
to
an
employee using an email address I physically typed into the code (I
am
only
learning and testing atm). I then tried to link it with a field, so
that
if I
type an email address into a field, it sends the task.

However, I don't actually want to do this in the final copy. The
Name
field
is a combo box with names of employees in it, and I ideally want to
be
able
to click an employee name, and it sends to the related email
address,
which
it should be looking up from tblEmployees.

Did that make any sense? :S



:

Dagre

I'm not quite clear on the relationships among your data.

If a single employee only handles a task (i.e., you don't assign
two
folks
to handle the task, not simultaneously nor consecutively), and if
you
don't
need to 'normalize' your tasks (for example, each task is unique --
never
the same task more than one time), then your table structure seems
appropriate.

However, if either of the 'contrary' conditions mentioned above can
happen,
you might need to have one table for employees, one table for
tasks,
and
a
third table to handle "assignments".

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

I have two tables, one called tblTasks, which contains task
information
to
be
assigned using Outlook. The other is called tblEmployees, and
includes
info
such as Name, Position, Department and Email.
tblTasks is related to tblEmployees through Employee Name. I have
added
code
to frmTasks which creates the task in Outlook, and Assigns it to
another
employee. Currently, I have got it looking in a text box which
contains
the
email address to send the task to.

I have a field in tblTasks called Name, which has the name of the
employee
which the task is going to be assigned to. I would prefer to be
able
to
select a name from the list, and it looks up the email address
from
tblEmployees, and assigns the task to that person.

Any ideas?
 
J

Jeff Boyce

Dagre

Open Access. Click on the HELP button. Type in DLookup.

The exact syntax and examples are provided.

Good luck

Regards

Jeff Boyce
Microsoft Office/Access MVP


Dagre said:
Sorry for the delay in replying...

I don't actually know how to do this. How would I go about using dlookup?

Jeff Boyce said:
Doesn't your Employee table include an email address?

One solution might be to use the DLookup() function to find the email
address that belongs to the Employee.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Dagre said:
If we had two employees with the same name, I think we would probably
do
something like add a middle initial for one of them, or possible add
the
department in brackets, something like that to make it unique.

I don't want to send the assignment until I press the Assign Task
button.
This is the existing code associated with the Assign Task button:

Private Sub btnSaveToTasks_Click()
Dim outTask As Outlook.TaskItem
Dim outApp As Outlook.Application
Set outApp = New Outlook.Application
Set outTask = outApp.CreateItem(olTaskItem)
outTask.DueDate = Me.Date
outTask.ReminderTime = Me.ReminderMinutes
outTask.Body = Me.Notes
outTask.Recipients.Add Me.EmployeeName
outTask.Assign
outTask.Send
Set outTask = Nothing
Set outApp = Nothing
End Sub

outTask.Recipients.Add is currently pointing to Employee Name, but in
order
to send I actually have to type an email address. I need to find a code
that
allows me to select a name, and it find the email address related to
that
name, if that makes any sense.



:

First off, using [EmployeeName] as a unique identifier (you are using
it
to
connect the tables) is risky. What will you do if you hire two "John
Doe"s?

It sounds like you want the combobox from which you pick an employee
to
automatically send an email. If so, check into the combobox's
AfterUpdate
event, and the SendObject() function.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Hmm, I don't think I explained too well.

I have two tables, tblTasks and tblEmployees, both related by
"Employee
Name" field.

I have been using a button on frmTasks, which let me assign a task
to
an
employee using an email address I physically typed into the code (I
am
only
learning and testing atm). I then tried to link it with a field, so
that
if I
type an email address into a field, it sends the task.

However, I don't actually want to do this in the final copy. The
Name
field
is a combo box with names of employees in it, and I ideally want to
be
able
to click an employee name, and it sends to the related email
address,
which
it should be looking up from tblEmployees.

Did that make any sense? :S



:

Dagre

I'm not quite clear on the relationships among your data.

If a single employee only handles a task (i.e., you don't assign
two
folks
to handle the task, not simultaneously nor consecutively), and if
you
don't
need to 'normalize' your tasks (for example, each task is unique --
never
the same task more than one time), then your table structure seems
appropriate.

However, if either of the 'contrary' conditions mentioned above can
happen,
you might need to have one table for employees, one table for
tasks,
and
a
third table to handle "assignments".

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

I have two tables, one called tblTasks, which contains task
information
to
be
assigned using Outlook. The other is called tblEmployees, and
includes
info
such as Name, Position, Department and Email.
tblTasks is related to tblEmployees through Employee Name. I have
added
code
to frmTasks which creates the task in Outlook, and Assigns it to
another
employee. Currently, I have got it looking in a text box which
contains
the
email address to send the task to.

I have a field in tblTasks called Name, which has the name of the
employee
which the task is going to be assigned to. I would prefer to be
able
to
select a name from the list, and it looks up the email address
from
tblEmployees, and assigns the task to that person.

Any ideas?
 

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

Similar Threads

Append and Delete 1
Findfirst problem 5
Lookup 2
Complicated Like Expression 3
wrong values in combo box selection 2
Beginner VBA help with multiple tables 11
Data Entry Form - 2 Tables 1
Report From Form 2

Top