Table reference syntax needed

  • Thread starter Thread starter Ronald Marchand
  • Start date Start date
R

Ronald Marchand

I know that this is not actually a query.
I have a form that has a value set in Me.ServiceID.
In a table Services (which is NOT the data source for the form) there is a
pair of values, ServiceID and ServiceName.

How can I find (specify) the ServiceName using Me.ServiceID?
I have an IF statement assigning Me.Description equal to this value

TIA
Ron
 
I would include the table Services in your form's record source. If you can't
do this, change the text box to a combo box with Services as the Row Source.
 
Duane Hookom said:
I would include the table Services in your form's record source. If you
can't
do this, change the text box to a combo box with Services as the Row
Source.

The field is a longer text field and I am attempting to set some default
text based on the serviceID code entered. During that lookup, the text is
visible to the user but I do not know how to capture it for "later" use.

Can you set a form to two different tables at the same time?

Thanks
Ron
 
Generally in a database, you store the "code" value in many tables and one
table where it is the primary key. You store the 'longer text field' in only
one record in one table. That is how relational databases work.
 
Thanks, but I think I have not explained my point properly.

In a nutshell. a service type is stored with its ID and NameDescription in
its table.
I am creating a table named "Events". One of the fields of this table
contains the ServiceType Key and is a combo box to look it up. During the
lookup the service name's description is visible to the user. After the
serviceID is assigned to the form, an after_update checks whether or not the
event description is null and if it is, it is to be set to the value
retrieved from the services table.

I do not understand how to assign the value, and yes I am new to database
development.

Ron
 
I guess I still don't understand. A value isn't "assigned to the form". A
control might be updated to a value. If the control value is null, I don't
understand how a value could be retrieved from another table.

Aren't you just storing the ServiceTypeID in the Events table? Don't you
select the ServiceTypeID from a combo box that displays the service type
description? Isn't that good enough? There generally is no good reason to
store both the ServiceTypeID and the NameDescription in the Events table.
This would be bad practice.
 
If all you want is to SHOW the value on your form, just set the control's
Control Source to something like

Control Source: =[NameofCombobox].Column(1)

Columns are zero-based so that will show the value of the 2nd column in the
your combobox. An alternative is the change the settings of the combobox so
that it displays the description while it stores the Service ID. Assuming
that you have a two column combobox, on the Properties Format tab of the
combobox set column widths as follows

Column Widths: 0;

That will hide the first column and display all the other columns that you
have in the combobox.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
This is close to what I want.

I am not showing anything. A ServiceID is selected as the service required
for this event. I am gathering the description of this service as a default
value for a memo box. The user can accept this, modify it or replace it
with whatever is necessary to describe the event.

My problem is that this "description" is not in the form's data source. But
I have the info to get it. Just do not understand how.

I want Services.serviceName where the key (ServicesID) is the value of
Event.ServiceID.

Thanks for trying.

Ron


John Spencer said:
If all you want is to SHOW the value on your form, just set the control's
Control Source to something like

Control Source: =[NameofCombobox].Column(1)

Columns are zero-based so that will show the value of the 2nd column in
the your combobox. An alternative is the change the settings of the
combobox so that it displays the description while it stores the Service
ID. Assuming that you have a two column combobox, on the Properties
Format tab of the combobox set column widths as follows

Column Widths: 0;

That will hide the first column and display all the other columns that you
have in the combobox.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

Ronald Marchand said:
Thanks, but I think I have not explained my point properly.

In a nutshell. a service type is stored with its ID and NameDescription
in its table.
I am creating a table named "Events". One of the fields of this table
contains the ServiceType Key and is a combo box to look it up. During
the lookup the service name's description is visible to the user. After
the serviceID is assigned to the form, an after_update checks whether or
not the event description is null and if it is, it is to be set to the
value retrieved from the services table.

I do not understand how to assign the value, and yes I am new to database
development.

Ron
 
Ronald,

Ok, you are saying that a ServiceID is "selected" - but you don't say how.
I'm assuming that its from a Combo-box and that you're made it like John
suggested
So, in that combobox's _AfterUpdate event,
do what John was trying to tell you to do.
put code in that does something like this:

if len(nz(me.txtMemoFieldCtlName.value, "") = 0) then _
me.txtMemoFieldCtlName.value = me.cboSelectServiceIDCtlNameHere.columns(1)

This will put the value of the selected row from the combox's 2nd column
into the MemoFieldCtlName textbox on your form (but only if it is already
empty).
You can easily enhance this code to ask the user if they want to replace
what's in the textbox with the description again if it isn't empty...or not.


Ronald Marchand said:
This is close to what I want.

I am not showing anything. A ServiceID is selected as the service required
for this event. I am gathering the description of this service as a default
value for a memo box. The user can accept this, modify it or replace it
with whatever is necessary to describe the event.

My problem is that this "description" is not in the form's data source. But
I have the info to get it. Just do not understand how.

I want Services.serviceName where the key (ServicesID) is the value of
Event.ServiceID.

Thanks for trying.

Ron


John Spencer said:
If all you want is to SHOW the value on your form, just set the control's
Control Source to something like

Control Source: =[NameofCombobox].Column(1)

Columns are zero-based so that will show the value of the 2nd column in
the your combobox. An alternative is the change the settings of the
combobox so that it displays the description while it stores the Service
ID. Assuming that you have a two column combobox, on the Properties
Format tab of the combobox set column widths as follows

Column Widths: 0;

That will hide the first column and display all the other columns that you
have in the combobox.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

Ronald Marchand said:
Thanks, but I think I have not explained my point properly.

In a nutshell. a service type is stored with its ID and NameDescription
in its table.
I am creating a table named "Events". One of the fields of this table
contains the ServiceType Key and is a combo box to look it up. During
the lookup the service name's description is visible to the user. After
the serviceID is assigned to the form, an after_update checks whether or
not the event description is null and if it is, it is to be set to the
value retrieved from the services table.

I do not understand how to assign the value, and yes I am new to database
development.

Ron


Generally in a database, you store the "code" value in many tables and
one
table where it is the primary key. You store the 'longer text field' in
only
one record in one table. That is how relational databases work.

--
Duane Hookom
Microsoft Access MVP


:

I would include the table Services in your form's record source. If
you
can't
do this, change the text box to a combo box with Services as the Row
Source.

The field is a longer text field and I am attempting to set some
default
text based on the serviceID code entered. During that lookup, the text
is
visible to the user but I do not know how to capture it for "later"
use.

Can you set a form to two different tables at the same time?

Thanks
Ron


--
Duane Hookom
Microsoft Access MVP


:

I know that this is not actually a query.
I have a form that has a value set in Me.ServiceID.
In a table Services (which is NOT the data source for the form)
there is
a
pair of values, ServiceID and ServiceName.

How can I find (specify) the ServiceName using Me.ServiceID?
I have an IF statement assigning Me.Description equal to this value

TIA
Ron
 
Thanks to all. And your assumption is correct, the user selects the value
from a combo-box. I will work with this.

Ron

Mark Burns said:
Ronald,

Ok, you are saying that a ServiceID is "selected" - but you don't say how.
I'm assuming that its from a Combo-box and that you're made it like John
suggested
So, in that combobox's _AfterUpdate event,
do what John was trying to tell you to do.
put code in that does something like this:

if len(nz(me.txtMemoFieldCtlName.value, "") = 0) then _
me.txtMemoFieldCtlName.value =
me.cboSelectServiceIDCtlNameHere.columns(1)

This will put the value of the selected row from the combox's 2nd column
into the MemoFieldCtlName textbox on your form (but only if it is already
empty).
You can easily enhance this code to ask the user if they want to replace
what's in the textbox with the description again if it isn't empty...or
not.


Ronald Marchand said:
This is close to what I want.

I am not showing anything. A ServiceID is selected as the service
required
for this event. I am gathering the description of this service as a
default
value for a memo box. The user can accept this, modify it or replace it
with whatever is necessary to describe the event.

My problem is that this "description" is not in the form's data source.
But
I have the info to get it. Just do not understand how.

I want Services.serviceName where the key (ServicesID) is the value of
Event.ServiceID.

Thanks for trying.

Ron


John Spencer said:
If all you want is to SHOW the value on your form, just set the
control's
Control Source to something like

Control Source: =[NameofCombobox].Column(1)

Columns are zero-based so that will show the value of the 2nd column in
the your combobox. An alternative is the change the settings of the
combobox so that it displays the description while it stores the
Service
ID. Assuming that you have a two column combobox, on the Properties
Format tab of the combobox set column widths as follows

Column Widths: 0;

That will hide the first column and display all the other columns that
you
have in the combobox.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

Thanks, but I think I have not explained my point properly.

In a nutshell. a service type is stored with its ID and
NameDescription
in its table.
I am creating a table named "Events". One of the fields of this table
contains the ServiceType Key and is a combo box to look it up. During
the lookup the service name's description is visible to the user.
After
the serviceID is assigned to the form, an after_update checks whether
or
not the event description is null and if it is, it is to be set to the
value retrieved from the services table.

I do not understand how to assign the value, and yes I am new to
database
development.

Ron


Generally in a database, you store the "code" value in many tables
and
one
table where it is the primary key. You store the 'longer text field'
in
only
one record in one table. That is how relational databases work.

--
Duane Hookom
Microsoft Access MVP


:

I would include the table Services in your form's record source. If
you
can't
do this, change the text box to a combo box with Services as the
Row
Source.

The field is a longer text field and I am attempting to set some
default
text based on the serviceID code entered. During that lookup, the
text
is
visible to the user but I do not know how to capture it for "later"
use.

Can you set a form to two different tables at the same time?

Thanks
Ron


--
Duane Hookom
Microsoft Access MVP


:

I know that this is not actually a query.
I have a form that has a value set in Me.ServiceID.
In a table Services (which is NOT the data source for the form)
there is
a
pair of values, ServiceID and ServiceName.

How can I find (specify) the ServiceName using Me.ServiceID?
I have an IF statement assigning Me.Description equal to this
value

TIA
Ron
 
Does the source of the combobox contain both the ServiceID and the
Description? It needs to if you are going to try to reference the second
column.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Ronald Marchand said:
Thanks to all. And your assumption is correct, the user selects the value
from a combo-box. I will work with this.

Ron

Mark Burns said:
Ronald,

Ok, you are saying that a ServiceID is "selected" - but you don't say
how.
I'm assuming that its from a Combo-box and that you're made it like John
suggested
So, in that combobox's _AfterUpdate event,
do what John was trying to tell you to do.
put code in that does something like this:

if len(nz(me.txtMemoFieldCtlName.value, "") = 0) then _
me.txtMemoFieldCtlName.value =
me.cboSelectServiceIDCtlNameHere.columns(1)

This will put the value of the selected row from the combox's 2nd column
into the MemoFieldCtlName textbox on your form (but only if it is already
empty).
You can easily enhance this code to ask the user if they want to replace
what's in the textbox with the description again if it isn't empty...or
not.


Ronald Marchand said:
This is close to what I want.

I am not showing anything. A ServiceID is selected as the service
required
for this event. I am gathering the description of this service as a
default
value for a memo box. The user can accept this, modify it or replace it
with whatever is necessary to describe the event.

My problem is that this "description" is not in the form's data source.
But
I have the info to get it. Just do not understand how.

I want Services.serviceName where the key (ServicesID) is the value of
Event.ServiceID.

Thanks for trying.

Ron


If all you want is to SHOW the value on your form, just set the
control's
Control Source to something like

Control Source: =[NameofCombobox].Column(1)

Columns are zero-based so that will show the value of the 2nd column
in
the your combobox. An alternative is the change the settings of the
combobox so that it displays the description while it stores the
Service
ID. Assuming that you have a two column combobox, on the Properties
Format tab of the combobox set column widths as follows

Column Widths: 0;

That will hide the first column and display all the other columns that
you
have in the combobox.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

Thanks, but I think I have not explained my point properly.

In a nutshell. a service type is stored with its ID and
NameDescription
in its table.
I am creating a table named "Events". One of the fields of this
table
contains the ServiceType Key and is a combo box to look it up.
During
the lookup the service name's description is visible to the user.
After
the serviceID is assigned to the form, an after_update checks whether
or
not the event description is null and if it is, it is to be set to
the
value retrieved from the services table.

I do not understand how to assign the value, and yes I am new to
database
development.

Ron


Generally in a database, you store the "code" value in many tables
and
one
table where it is the primary key. You store the 'longer text field'
in
only
one record in one table. That is how relational databases work.

--
Duane Hookom
Microsoft Access MVP


:

I would include the table Services in your form's record source.
If
you
can't
do this, change the text box to a combo box with Services as the
Row
Source.

The field is a longer text field and I am attempting to set some
default
text based on the serviceID code entered. During that lookup, the
text
is
visible to the user but I do not know how to capture it for "later"
use.

Can you set a form to two different tables at the same time?

Thanks
Ron


--
Duane Hookom
Microsoft Access MVP


:

I know that this is not actually a query.
I have a form that has a value set in Me.ServiceID.
In a table Services (which is NOT the data source for the form)
there is
a
pair of values, ServiceID and ServiceName.

How can I find (specify) the ServiceName using Me.ServiceID?
I have an IF statement assigning Me.Description equal to this
value

TIA
Ron
 
Thanks for the warning. Yes it does. They are the only two fields in the
table.

Ron

John Spencer said:
Does the source of the combobox contain both the ServiceID and the
Description? It needs to if you are going to try to reference the second
column.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

Ronald Marchand said:
Thanks to all. And your assumption is correct, the user selects the
value from a combo-box. I will work with this.

Ron

Mark Burns said:
Ronald,

Ok, you are saying that a ServiceID is "selected" - but you don't say
how.
I'm assuming that its from a Combo-box and that you're made it like John
suggested
So, in that combobox's _AfterUpdate event,
do what John was trying to tell you to do.
put code in that does something like this:

if len(nz(me.txtMemoFieldCtlName.value, "") = 0) then _
me.txtMemoFieldCtlName.value =
me.cboSelectServiceIDCtlNameHere.columns(1)

This will put the value of the selected row from the combox's 2nd column
into the MemoFieldCtlName textbox on your form (but only if it is
already
empty).
You can easily enhance this code to ask the user if they want to replace
what's in the textbox with the description again if it isn't empty...or
not.


:

This is close to what I want.

I am not showing anything. A ServiceID is selected as the service
required
for this event. I am gathering the description of this service as a
default
value for a memo box. The user can accept this, modify it or replace
it
with whatever is necessary to describe the event.

My problem is that this "description" is not in the form's data source.
But
I have the info to get it. Just do not understand how.

I want Services.serviceName where the key (ServicesID) is the value of
Event.ServiceID.

Thanks for trying.

Ron


If all you want is to SHOW the value on your form, just set the
control's
Control Source to something like

Control Source: =[NameofCombobox].Column(1)

Columns are zero-based so that will show the value of the 2nd column
in
the your combobox. An alternative is the change the settings of the
combobox so that it displays the description while it stores the
Service
ID. Assuming that you have a two column combobox, on the Properties
Format tab of the combobox set column widths as follows

Column Widths: 0;

That will hide the first column and display all the other columns
that you
have in the combobox.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

Thanks, but I think I have not explained my point properly.

In a nutshell. a service type is stored with its ID and
NameDescription
in its table.
I am creating a table named "Events". One of the fields of this
table
contains the ServiceType Key and is a combo box to look it up.
During
the lookup the service name's description is visible to the user.
After
the serviceID is assigned to the form, an after_update checks
whether or
not the event description is null and if it is, it is to be set to
the
value retrieved from the services table.

I do not understand how to assign the value, and yes I am new to
database
development.

Ron


Generally in a database, you store the "code" value in many tables
and
one
table where it is the primary key. You store the 'longer text
field' in
only
one record in one table. That is how relational databases work.

--
Duane Hookom
Microsoft Access MVP


:

I would include the table Services in your form's record source.
If
you
can't
do this, change the text box to a combo box with Services as the
Row
Source.

The field is a longer text field and I am attempting to set some
default
text based on the serviceID code entered. During that lookup, the
text
is
visible to the user but I do not know how to capture it for
"later"
use.

Can you set a form to two different tables at the same time?

Thanks
Ron


--
Duane Hookom
Microsoft Access MVP


:

I know that this is not actually a query.
I have a form that has a value set in Me.ServiceID.
In a table Services (which is NOT the data source for the form)
there is
a
pair of values, ServiceID and ServiceName.

How can I find (specify) the ServiceName using Me.ServiceID?
I have an IF statement assigning Me.Description equal to this
value

TIA
Ron
 

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


Back
Top