combo box select

T

Tanya

Hi
I am having difficulty creating a combo box which behaves how I want it to.

Main Form I need to access Student Table:
StudentID
Surname
FirstName
Scholastic Year
Gender

Subform
Accesses another table called Unform Infringements

What I want to do is have a combo box which allows me to search for the
student by Surname&", "&FirstName which then updates the other fields in main
form, then in turn allows user to update subform.

There must be something I am missing here... I created a combo box with the
following row source for FullName
SELECT Students.StudentID, [Surname] & ", " & [FirstName] AS [Full Name]
FROM Students ORDER BY [Surname] & ", " & [FirstName];

and the error I am getting...

"The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship.
Changethe data in the field or fields that c ontain dulicate data, remove the
index, or redefine the index to permit duplicate entries and try again."

Where am I going wrong please someone...

regards
Tanya
 
K

Ken Snell \(MVP\)

You didn't post any code or details that would tell us how you're trying to
save/edit the data in the form/subform, using the combo box's selection.
Please tell us more details.
 
T

Tanya

Hi Ken
I am not sure what imformation you asking for.
When I set up the form I dragged the sub-form onto the main form.

The student and uniform tables are related by studentID and if I use normal
textbox for each field in student there is no problem. The problem only
arises when I want to make it easier to find a particular student to update
the unform infringements table. Otherwise the form works fine.

cheers
Tana

Ken Snell (MVP) said:
You didn't post any code or details that would tell us how you're trying to
save/edit the data in the form/subform, using the combo box's selection.
Please tell us more details.

--

Ken Snell
<MS ACCESS MVP>


Tanya said:
Hi
I am having difficulty creating a combo box which behaves how I want it
to.

Main Form I need to access Student Table:
StudentID
Surname
FirstName
Scholastic Year
Gender

Subform
Accesses another table called Unform Infringements

What I want to do is have a combo box which allows me to search for the
student by Surname&", "&FirstName which then updates the other fields in
main
form, then in turn allows user to update subform.

There must be something I am missing here... I created a combo box with
the
following row source for FullName
SELECT Students.StudentID, [Surname] & ", " & [FirstName] AS [Full Name]
FROM Students ORDER BY [Surname] & ", " & [FirstName];

and the error I am getting...

"The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship.
Changethe data in the field or fields that c ontain dulicate data, remove
the
index, or redefine the index to permit duplicate entries and try again."

Where am I going wrong please someone...

regards
Tanya
 
K

Ken Snell \(MVP\)

Are you wanting to use a combobox instead of a textbox on the form, thereby
allowing the user to select an entry instead of having to type the full
entry into the textbox? If yes, what is the ControlSource of the combobox --
it should be the name of the field that is to receive the chosen entry. And
the BoundColumn property of that combobox must the column number (starting
at 1 for the first field in the RowSource query's list of fields) that
contains the value that is to be saved into that field -- in your case, I
believe the correct value for BoundColumn is 1.
--

Ken Snell
<MS ACCESS MVP>




Tanya said:
Hi Ken
I am not sure what imformation you asking for.
When I set up the form I dragged the sub-form onto the main form.

The student and uniform tables are related by studentID and if I use
normal
textbox for each field in student there is no problem. The problem only
arises when I want to make it easier to find a particular student to
update
the unform infringements table. Otherwise the form works fine.

cheers
Tana

Ken Snell (MVP) said:
You didn't post any code or details that would tell us how you're trying
to
save/edit the data in the form/subform, using the combo box's selection.
Please tell us more details.

--

Ken Snell
<MS ACCESS MVP>


Tanya said:
Hi
I am having difficulty creating a combo box which behaves how I want it
to.

Main Form I need to access Student Table:
StudentID
Surname
FirstName
Scholastic Year
Gender

Subform
Accesses another table called Unform Infringements

What I want to do is have a combo box which allows me to search for the
student by Surname&", "&FirstName which then updates the other fields
in
main
form, then in turn allows user to update subform.

There must be something I am missing here... I created a combo box
with
the
following row source for FullName
SELECT Students.StudentID, [Surname] & ", " & [FirstName] AS [Full
Name]
FROM Students ORDER BY [Surname] & ", " & [FirstName];

and the error I am getting...

"The changes you requested to the table were not successful because
they
would create duplicate values in the index, primary key, or
relationship.
Changethe data in the field or fields that c ontain dulicate data,
remove
the
index, or redefine the index to permit duplicate entries and try
again."

Where am I going wrong please someone...

regards
Tanya
 
T

Tanya

Thanks Ken

Ken Snell (MVP) said:
Are you wanting to use a combobox instead of a textbox on the form, thereby
allowing the user to select an entry instead of having to type the full
entry into the textbox? If yes, what is the ControlSource of the combobox --
it should be the name of the field that is to receive the chosen entry. And
the BoundColumn property of that combobox must the column number (starting
at 1 for the first field in the RowSource query's list of fields) that
contains the value that is to be saved into that field -- in your case, I
believe the correct value for BoundColumn is 1.
--

Ken Snell
<MS ACCESS MVP>




Tanya said:
Hi Ken
I am not sure what imformation you asking for.
When I set up the form I dragged the sub-form onto the main form.

The student and uniform tables are related by studentID and if I use
normal
textbox for each field in student there is no problem. The problem only
arises when I want to make it easier to find a particular student to
update
the unform infringements table. Otherwise the form works fine.

cheers
Tana

Ken Snell (MVP) said:
You didn't post any code or details that would tell us how you're trying
to
save/edit the data in the form/subform, using the combo box's selection.
Please tell us more details.

--

Ken Snell
<MS ACCESS MVP>


Hi
I am having difficulty creating a combo box which behaves how I want it
to.

Main Form I need to access Student Table:
StudentID
Surname
FirstName
Scholastic Year
Gender

Subform
Accesses another table called Unform Infringements

What I want to do is have a combo box which allows me to search for the
student by Surname&", "&FirstName which then updates the other fields
in
main
form, then in turn allows user to update subform.

There must be something I am missing here... I created a combo box
with
the
following row source for FullName
SELECT Students.StudentID, [Surname] & ", " & [FirstName] AS [Full
Name]
FROM Students ORDER BY [Surname] & ", " & [FirstName];

and the error I am getting...

"The changes you requested to the table were not successful because
they
would create duplicate values in the index, primary key, or
relationship.
Changethe data in the field or fields that c ontain dulicate data,
remove
the
index, or redefine the index to permit duplicate entries and try
again."

Where am I going wrong please someone...

regards
Tanya
 

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