If I enter in one the other auto populate.

C

Candace

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
K

Klatuu

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
 
C

Candace

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???
 
K

Klatuu

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
 
C

Candace

I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

Klatuu said:
Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


Candace said:
I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???
 
K

Klatuu

Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


Candace said:
I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

Klatuu said:
Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


Candace said:
I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
C

Candace

=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

Klatuu said:
Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


Candace said:
I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

Klatuu said:
Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
K

Klatuu

You don't need that expression.
If you will follow my instructions, you will get what you are trying to do.
--
Dave Hargis, Microsoft Access MVP


Candace said:
=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

Klatuu said:
Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


Candace said:
I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

:

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
C

Candace

I have followed all of the steps.....

In the Combo's After Update, you populate the Customer ID control....the
only thing available here is [Event Procedure]...nothing else
I am not sure what you are asking me to do in this step

Klatuu said:
You don't need that expression.
If you will follow my instructions, you will get what you are trying to do.
--
Dave Hargis, Microsoft Access MVP


Candace said:
=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

Klatuu said:
Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


:

I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

:

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
K

Klatuu

Okay. Here is what you need to do.
Open the properties dialog and select the events tab
Click the small command button to the right of the box that says After Update.
Choose Code builder.
The VB Editor will open.
There bill be a Private Sub controlname_AfterUpdate() line followed by an
End Sub line.
Put the code I posted between those two lines.
Now on the menu bar click Debug, Compile. see if you get any errors and
post back. We will take it from there.
--
Dave Hargis, Microsoft Access MVP


Candace said:
I have followed all of the steps.....

In the Combo's After Update, you populate the Customer ID control....the
only thing available here is [Event Procedure]...nothing else
I am not sure what you are asking me to do in this step

Klatuu said:
You don't need that expression.
If you will follow my instructions, you will get what you are trying to do.
--
Dave Hargis, Microsoft Access MVP


Candace said:
=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

:

Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


:

I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

:

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
C

Candace

Ok I have done that. I now get a runtime error. The value you entered isn't
valid for this field. I can see that it is pulling the information for the
Company names but the value for the company ID is showing 0.

Klatuu said:
Okay. Here is what you need to do.
Open the properties dialog and select the events tab
Click the small command button to the right of the box that says After Update.
Choose Code builder.
The VB Editor will open.
There bill be a Private Sub controlname_AfterUpdate() line followed by an
End Sub line.
Put the code I posted between those two lines.
Now on the menu bar click Debug, Compile. see if you get any errors and
post back. We will take it from there.
--
Dave Hargis, Microsoft Access MVP


Candace said:
I have followed all of the steps.....

In the Combo's After Update, you populate the Customer ID control....the
only thing available here is [Event Procedure]...nothing else
I am not sure what you are asking me to do in this step

Klatuu said:
You don't need that expression.
If you will follow my instructions, you will get what you are trying to do.
--
Dave Hargis, Microsoft Access MVP


:

=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

:

Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


:

I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

:

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
K

Klatuu

"I want to select the Company name and then then Customer ID will"
Let's be sure we have our names correct. Is it customer id or company id,
or are there both?
On which line did you get the error?

--
Dave Hargis, Microsoft Access MVP


Candace said:
Ok I have done that. I now get a runtime error. The value you entered isn't
valid for this field. I can see that it is pulling the information for the
Company names but the value for the company ID is showing 0.

Klatuu said:
Okay. Here is what you need to do.
Open the properties dialog and select the events tab
Click the small command button to the right of the box that says After Update.
Choose Code builder.
The VB Editor will open.
There bill be a Private Sub controlname_AfterUpdate() line followed by an
End Sub line.
Put the code I posted between those two lines.
Now on the menu bar click Debug, Compile. see if you get any errors and
post back. We will take it from there.
--
Dave Hargis, Microsoft Access MVP


Candace said:
I have followed all of the steps.....

In the Combo's After Update, you populate the Customer ID control....the
only thing available here is [Event Procedure]...nothing else
I am not sure what you are asking me to do in this step

:

You don't need that expression.
If you will follow my instructions, you will get what you are trying to do.
--
Dave Hargis, Microsoft Access MVP


:

=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

:

Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


:

I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

:

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
C

Candace

It is Company Name and Company ID, I am entering them into VB this way as
well...it does allow me to chose them from a drop down. The error message
says Run-time error '-214352567 )80020009)': The value you entered isn't
valid for this field. If I press Debug, it takes me to the VB screen and
what I had entered in (Company_ID=Company_Name) is highlighted in
yellow.....what do I keep doing wrong???

Klatuu said:
"I want to select the Company name and then then Customer ID will"
Let's be sure we have our names correct. Is it customer id or company id,
or are there both?
On which line did you get the error?

--
Dave Hargis, Microsoft Access MVP


Candace said:
Ok I have done that. I now get a runtime error. The value you entered isn't
valid for this field. I can see that it is pulling the information for the
Company names but the value for the company ID is showing 0.

Klatuu said:
Okay. Here is what you need to do.
Open the properties dialog and select the events tab
Click the small command button to the right of the box that says After Update.
Choose Code builder.
The VB Editor will open.
There bill be a Private Sub controlname_AfterUpdate() line followed by an
End Sub line.
Put the code I posted between those two lines.
Now on the menu bar click Debug, Compile. see if you get any errors and
post back. We will take it from there.
--
Dave Hargis, Microsoft Access MVP


:

I have followed all of the steps.....

In the Combo's After Update, you populate the Customer ID control....the
only thing available here is [Event Procedure]...nothing else
I am not sure what you are asking me to do in this step

:

You don't need that expression.
If you will follow my instructions, you will get what you are trying to do.
--
Dave Hargis, Microsoft Access MVP


:

=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

:

Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


:

I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

:

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
K

Klatuu

What you need is to put the value returned by the combo in the text box.
What you are doing is trying to put a text value in a numeric field. You
should also qualify the name of your controls with a reference to the form so
(change the names to the names of your controls)

Me.NameOfCompanyIDTextBox = Me.NameOfComboBox
--
Dave Hargis, Microsoft Access MVP


Candace said:
It is Company Name and Company ID, I am entering them into VB this way as
well...it does allow me to chose them from a drop down. The error message
says Run-time error '-214352567 )80020009)': The value you entered isn't
valid for this field. If I press Debug, it takes me to the VB screen and
what I had entered in (Company_ID=Company_Name) is highlighted in
yellow.....what do I keep doing wrong???

Klatuu said:
"I want to select the Company name and then then Customer ID will"
Let's be sure we have our names correct. Is it customer id or company id,
or are there both?
On which line did you get the error?

--
Dave Hargis, Microsoft Access MVP


Candace said:
Ok I have done that. I now get a runtime error. The value you entered isn't
valid for this field. I can see that it is pulling the information for the
Company names but the value for the company ID is showing 0.

:

Okay. Here is what you need to do.
Open the properties dialog and select the events tab
Click the small command button to the right of the box that says After Update.
Choose Code builder.
The VB Editor will open.
There bill be a Private Sub controlname_AfterUpdate() line followed by an
End Sub line.
Put the code I posted between those two lines.
Now on the menu bar click Debug, Compile. see if you get any errors and
post back. We will take it from there.
--
Dave Hargis, Microsoft Access MVP


:

I have followed all of the steps.....

In the Combo's After Update, you populate the Customer ID control....the
only thing available here is [Event Procedure]...nothing else
I am not sure what you are asking me to do in this step

:

You don't need that expression.
If you will follow my instructions, you will get what you are trying to do.
--
Dave Hargis, Microsoft Access MVP


:

=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

:

Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


:

I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

:

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
C

Candace

None of this is working...I have copy and pasted exactly what you have typed
below, entered in the EXACT name of the boxes and it still comes back with an
error. Not only that but it has done something to my original table??

Klatuu said:
What you need is to put the value returned by the combo in the text box.
What you are doing is trying to put a text value in a numeric field. You
should also qualify the name of your controls with a reference to the form so
(change the names to the names of your controls)

Me.NameOfCompanyIDTextBox = Me.NameOfComboBox
--
Dave Hargis, Microsoft Access MVP


Candace said:
It is Company Name and Company ID, I am entering them into VB this way as
well...it does allow me to chose them from a drop down. The error message
says Run-time error '-214352567 )80020009)': The value you entered isn't
valid for this field. If I press Debug, it takes me to the VB screen and
what I had entered in (Company_ID=Company_Name) is highlighted in
yellow.....what do I keep doing wrong???

Klatuu said:
"I want to select the Company name and then then Customer ID will"
Let's be sure we have our names correct. Is it customer id or company id,
or are there both?
On which line did you get the error?

--
Dave Hargis, Microsoft Access MVP


:

Ok I have done that. I now get a runtime error. The value you entered isn't
valid for this field. I can see that it is pulling the information for the
Company names but the value for the company ID is showing 0.

:

Okay. Here is what you need to do.
Open the properties dialog and select the events tab
Click the small command button to the right of the box that says After Update.
Choose Code builder.
The VB Editor will open.
There bill be a Private Sub controlname_AfterUpdate() line followed by an
End Sub line.
Put the code I posted between those two lines.
Now on the menu bar click Debug, Compile. see if you get any errors and
post back. We will take it from there.
--
Dave Hargis, Microsoft Access MVP


:

I have followed all of the steps.....

In the Combo's After Update, you populate the Customer ID control....the
only thing available here is [Event Procedure]...nothing else
I am not sure what you are asking me to do in this step

:

You don't need that expression.
If you will follow my instructions, you will get what you are trying to do.
--
Dave Hargis, Microsoft Access MVP


:

=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

:

Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


:

I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

:

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
K

Klatuu

Candace, I don't mean to be rude, but please adjust your attitude.
What I am trying to help you with is a very common ordinary thing to do. It
does work if you do it correctly. If it is not working, then you just aren't
doing it right.
I have posted code and instructions on how to use it. As I have said, you
have to use your own object name correctly for it to work.

Now, If you want to get it to work, and can help me out, I will glady help
you get it to work. To do so, I need the following information. I need it
all.

The name of the field in the table that has the company id
The name of the field in the table that has the company name
The name of the form control bound to the company id
Confrim the Control Source Property of this control is the company id field
The query of the combo box Row Source Property
The value of the following combo properties:
Colmun Count
Bound Column
The VBA code in the combo's After Update event as it is now.

--
Dave Hargis, Microsoft Access MVP


Candace said:
None of this is working...I have copy and pasted exactly what you have typed
below, entered in the EXACT name of the boxes and it still comes back with an
error. Not only that but it has done something to my original table??

Klatuu said:
What you need is to put the value returned by the combo in the text box.
What you are doing is trying to put a text value in a numeric field. You
should also qualify the name of your controls with a reference to the form so
(change the names to the names of your controls)

Me.NameOfCompanyIDTextBox = Me.NameOfComboBox
--
Dave Hargis, Microsoft Access MVP


Candace said:
It is Company Name and Company ID, I am entering them into VB this way as
well...it does allow me to chose them from a drop down. The error message
says Run-time error '-214352567 )80020009)': The value you entered isn't
valid for this field. If I press Debug, it takes me to the VB screen and
what I had entered in (Company_ID=Company_Name) is highlighted in
yellow.....what do I keep doing wrong???

:

"I want to select the Company name and then then Customer ID will"
Let's be sure we have our names correct. Is it customer id or company id,
or are there both?
On which line did you get the error?

--
Dave Hargis, Microsoft Access MVP


:

Ok I have done that. I now get a runtime error. The value you entered isn't
valid for this field. I can see that it is pulling the information for the
Company names but the value for the company ID is showing 0.

:

Okay. Here is what you need to do.
Open the properties dialog and select the events tab
Click the small command button to the right of the box that says After Update.
Choose Code builder.
The VB Editor will open.
There bill be a Private Sub controlname_AfterUpdate() line followed by an
End Sub line.
Put the code I posted between those two lines.
Now on the menu bar click Debug, Compile. see if you get any errors and
post back. We will take it from there.
--
Dave Hargis, Microsoft Access MVP


:

I have followed all of the steps.....

In the Combo's After Update, you populate the Customer ID control....the
only thing available here is [Event Procedure]...nothing else
I am not sure what you are asking me to do in this step

:

You don't need that expression.
If you will follow my instructions, you will get what you are trying to do.
--
Dave Hargis, Microsoft Access MVP


:

=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

:

Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


:

I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

:

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
C

Candace

I have been doing exactly what you have said and I am sorry if my frustration
is showing in my words but when the issue begins to get worse I get a little
worried. I am sure this is a very common ordinary thing to do for you or any
other user that has used the program quite often... if my "attitude" is
coming across as rude or defensive it is due to the direction being given, I
clearly stated in my first email I was a beginner with the program. Patience
and terminology should be adjsuted in this case and appropriate measures
should be taken...
I will contact other resources.

Thank you for your time.

Klatuu said:
Candace, I don't mean to be rude, but please adjust your attitude.
What I am trying to help you with is a very common ordinary thing to do. It
does work if you do it correctly. If it is not working, then you just aren't
doing it right.
I have posted code and instructions on how to use it. As I have said, you
have to use your own object name correctly for it to work.

Now, If you want to get it to work, and can help me out, I will glady help
you get it to work. To do so, I need the following information. I need it
all.

The name of the field in the table that has the company id
The name of the field in the table that has the company name
The name of the form control bound to the company id
Confrim the Control Source Property of this control is the company id field
The query of the combo box Row Source Property
The value of the following combo properties:
Colmun Count
Bound Column
The VBA code in the combo's After Update event as it is now.

--
Dave Hargis, Microsoft Access MVP


Candace said:
None of this is working...I have copy and pasted exactly what you have typed
below, entered in the EXACT name of the boxes and it still comes back with an
error. Not only that but it has done something to my original table??

Klatuu said:
What you need is to put the value returned by the combo in the text box.
What you are doing is trying to put a text value in a numeric field. You
should also qualify the name of your controls with a reference to the form so
(change the names to the names of your controls)

Me.NameOfCompanyIDTextBox = Me.NameOfComboBox
--
Dave Hargis, Microsoft Access MVP


:

It is Company Name and Company ID, I am entering them into VB this way as
well...it does allow me to chose them from a drop down. The error message
says Run-time error '-214352567 )80020009)': The value you entered isn't
valid for this field. If I press Debug, it takes me to the VB screen and
what I had entered in (Company_ID=Company_Name) is highlighted in
yellow.....what do I keep doing wrong???

:

"I want to select the Company name and then then Customer ID will"
Let's be sure we have our names correct. Is it customer id or company id,
or are there both?
On which line did you get the error?

--
Dave Hargis, Microsoft Access MVP


:

Ok I have done that. I now get a runtime error. The value you entered isn't
valid for this field. I can see that it is pulling the information for the
Company names but the value for the company ID is showing 0.

:

Okay. Here is what you need to do.
Open the properties dialog and select the events tab
Click the small command button to the right of the box that says After Update.
Choose Code builder.
The VB Editor will open.
There bill be a Private Sub controlname_AfterUpdate() line followed by an
End Sub line.
Put the code I posted between those two lines.
Now on the menu bar click Debug, Compile. see if you get any errors and
post back. We will take it from there.
--
Dave Hargis, Microsoft Access MVP


:

I have followed all of the steps.....

In the Combo's After Update, you populate the Customer ID control....the
only thing available here is [Event Procedure]...nothing else
I am not sure what you are asking me to do in this step

:

You don't need that expression.
If you will follow my instructions, you will get what you are trying to do.
--
Dave Hargis, Microsoft Access MVP


:

=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

:

Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


:

I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

:

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 
K

Klatuu

Do what you want.
I know you are a beginner and I have tried to be very detailed and get you
through it.
Certainly I understand your frustration, but there is no need to attack me
or the solution.
If you had done exactly as I instructed, it would be working by now.
You don't seem to have much patience and you don't follow instructions very
well. That is evident in your original post when you said no one had been
able to help you.
Are you aware these newsgroups are not manned by Microsoft? We are all
volunteers spending our own time to learn and to help others. It is not any
official support site.

Maybe working in database applications is not the right career path for you.
--
Dave Hargis, Microsoft Access MVP


Candace said:
I have been doing exactly what you have said and I am sorry if my frustration
is showing in my words but when the issue begins to get worse I get a little
worried. I am sure this is a very common ordinary thing to do for you or any
other user that has used the program quite often... if my "attitude" is
coming across as rude or defensive it is due to the direction being given, I
clearly stated in my first email I was a beginner with the program. Patience
and terminology should be adjsuted in this case and appropriate measures
should be taken...
I will contact other resources.

Thank you for your time.

Klatuu said:
Candace, I don't mean to be rude, but please adjust your attitude.
What I am trying to help you with is a very common ordinary thing to do. It
does work if you do it correctly. If it is not working, then you just aren't
doing it right.
I have posted code and instructions on how to use it. As I have said, you
have to use your own object name correctly for it to work.

Now, If you want to get it to work, and can help me out, I will glady help
you get it to work. To do so, I need the following information. I need it
all.

The name of the field in the table that has the company id
The name of the field in the table that has the company name
The name of the form control bound to the company id
Confrim the Control Source Property of this control is the company id field
The query of the combo box Row Source Property
The value of the following combo properties:
Colmun Count
Bound Column
The VBA code in the combo's After Update event as it is now.

--
Dave Hargis, Microsoft Access MVP


Candace said:
None of this is working...I have copy and pasted exactly what you have typed
below, entered in the EXACT name of the boxes and it still comes back with an
error. Not only that but it has done something to my original table??

:

What you need is to put the value returned by the combo in the text box.
What you are doing is trying to put a text value in a numeric field. You
should also qualify the name of your controls with a reference to the form so
(change the names to the names of your controls)

Me.NameOfCompanyIDTextBox = Me.NameOfComboBox
--
Dave Hargis, Microsoft Access MVP


:

It is Company Name and Company ID, I am entering them into VB this way as
well...it does allow me to chose them from a drop down. The error message
says Run-time error '-214352567 )80020009)': The value you entered isn't
valid for this field. If I press Debug, it takes me to the VB screen and
what I had entered in (Company_ID=Company_Name) is highlighted in
yellow.....what do I keep doing wrong???

:

"I want to select the Company name and then then Customer ID will"
Let's be sure we have our names correct. Is it customer id or company id,
or are there both?
On which line did you get the error?

--
Dave Hargis, Microsoft Access MVP


:

Ok I have done that. I now get a runtime error. The value you entered isn't
valid for this field. I can see that it is pulling the information for the
Company names but the value for the company ID is showing 0.

:

Okay. Here is what you need to do.
Open the properties dialog and select the events tab
Click the small command button to the right of the box that says After Update.
Choose Code builder.
The VB Editor will open.
There bill be a Private Sub controlname_AfterUpdate() line followed by an
End Sub line.
Put the code I posted between those two lines.
Now on the menu bar click Debug, Compile. see if you get any errors and
post back. We will take it from there.
--
Dave Hargis, Microsoft Access MVP


:

I have followed all of the steps.....

In the Combo's After Update, you populate the Customer ID control....the
only thing available here is [Event Procedure]...nothing else
I am not sure what you are asking me to do in this step

:

You don't need that expression.
If you will follow my instructions, you will get what you are trying to do.
--
Dave Hargis, Microsoft Access MVP


:

=Customers!CompanyID=Customers!CompanyName is the expression, I used the
expression builder to get the correct names etc.

I am not sure where exactly the error is occuring it doesn't give me that
much information. The last thread was an exact of the original error message.

:

Please post the code and point out the line where the error is occuring.
--
Dave Hargis, Microsoft Access MVP


:

I think the issue is within the expression. I am getting an error message
that reads as follows:

The expression After Update you entered as the event property setting
produced the following error: The object doesn't contain the Automation
object 'Customers'

:

Bound means the control has the name of a field in the form's record source
in its Control Sourece property so that it displays the fields value of the
current record and if you change the value in the control, the field in the
table is updated.

Unbound means the control does not have a record source field in the Control
Sourece property and does not display or update a field in the from's record
source.

What you are wanting to do is very common.
Customer ID should be a text box. It is best not to use Spaces in names.
Let's name it txtCustomerID.
Company Name should be a Combo box (drop down). Let's name it cboCompany
Here is how you show only the company name to the user, but put the Customer
ID value in the text box.

First let's set up the Combo's properties like they need to be.
Row Source Type: Table/Query
Row Source: SELECT [Customer ID], [Company Name] FROM [Customer Table];
Column Count: 2
Column Widths: 0"; 2" (The 0" will hide the customer id, make the 2" however
wide
it nees to be to show the company name)
Bound Column: 1 (This can be confusing. It is not the same as a bound
column. It
just defines which column of the combo's row
source will be
returned as the combo's value)

Now, in the Combo's After Update, you populate the txtCustomerID control
with the value in the Combo's first column:

Me.txtCustomerID = Me.cboCompany

My names may not be exactly the same as yours, so you can change the names I
used to use your actual names.
--
Dave Hargis, Microsoft Access MVP


:

I have followed what you have said and it is still not working...now I have
my combo box listing both fields that appear in my Custombers table and not
having just the name to select and the Customer ID populating to the previous
field.

I am not sure what you mean by "bound" either...

My Form is setup as follows:

Customer ID (#): is currently a drop down box...am not sure if this has any
weight on the issue, maybe s/b a txt. field?

Company Name: is also a drop down box that pulls from the Customer Table (2
columns, Customer ID and Company Name)

I want to select the Company name and then then Customer ID will
populate...I thought that I could do this by building an expression but can't
seem to get that to work either...I didn't realize it was this difficult to
link 2 fields that exist in the same table???

:

You did not say how you are trying to do this, so I will offer a few things
to check.
Based on your post, I assume the Combo is an unbound control and you have a
control bound to the Customer ID you are trying to populate based on the
selection from the Combo.
First, you Combo's row source should be something like:
SELECT CustomerID, CustomerName FROM tblCustomer ORDER BY CustomerName;

The Bound Column property should be 1
The Column Count property should be 2

You should use the Combo's After Update event to populate the bound control

Me.txtCustomerID = Me.cboCustomerSearch

The names are made up, you will need to use your actual field and control
names.
--
Dave Hargis, Microsoft Access MVP


:

I have reviewed the solutions as suggested in the forum but am unable to make
the autopopulate function work in my form.

I have a single combo box that runs off a customers table that consists of 2
columns, Customer ID (Number format) and the Company Name.

I need to have the company name selected from the combo box and then the
Customer ID# populate within the form field and cannot get this to work.

Please assist. (Beginner user)

Candace
 

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