PC Review


Reply
Thread Tools Rate Thread

combo box help and subform !!!! please help!

 
 
=?Utf-8?B?dHJldmk=?=
Guest
Posts: n/a
 
      22nd Dec 2006
Hi,
I have a combo box on my main form based on a table. Then I have a table in
the subform that works off another table. They are linked by ID. I linked
the child / parent and I can go through each record, but when I try to put my
cursor in the bottom half (subform) it tells me that I can't insert duplicate
data. I have absolutely no idea why and I was told that I dont need to put
any VBA code in to make it work. I am really lost. Can you please give me
some tips?

I tried creating my own combo box from scratch, one from the wizard and one
which I 'changed' to a combo box and nothing works. Thanks for helping.
 
Reply With Quote
 
 
 
 
strive4peace
Guest
Posts: n/a
 
      23rd Dec 2006
My guess is either

1. that the RecordSource for the subform includes that table for the
main form

OR

2. when you set up the structure for the related table, you started by
copying the structure for the parent table and didn't remove the Unique
index on the parent ID

Turn the Indexes window on when you are in the table design
from the menu --> View, Indexes

and look at what is set up

These are just wild guesses because you haven't given enough information
to really know what is going on.

What is the RecordSource for the mainform? for the subform? What is the
structure for your tables?

as for setting up a combobox, here is an example of properties that need
to be set:

*** Combobox Example ***

* Under no circumstances should you store names in more than one place.
For instance, if you have a People table, define a PID (or PeopleID)
autonumber field. Then, in other tables, when you want to identify a
person, you can use the key field. One way to do this…

Create an autonumber field in the People table -->

PID, autonumber

then, in the other tables...
PID, long, DefaultValue = Null

Then, when you want to put data in (which should be done from a form),
you can set it up to pick names from a list but store the PID.

create a combobox control

Name --> PID

ControlSource --> PID

RowSource -->
SELECT
PID,
LastName & ", " & Firstname AS Fullname,
BirthDate
FROM People
ORDER BY LastName, Firstname

BoundColumn --> 1

ColumnCount --> 3

columnWidths --> 0;2;1
(etc for however many columns you have -- the ID column will be hidden)

ListWidth --> 3
(should add up to the sum of the column widths)

if you have a listbox, sometimes you need to make the width .01 more
than the sum of the columns to prevent the horizontal scrollbar from
appearing.

PID will be stored in the form RecordSource while showing you names from
another table... a MUCH better and more reliable method.

If you want to show other information from your combobox in other
controls, you can use calculated fields. For instance

textbox:
Name --> BirthDate
ControlSource --> = PID.column(2)

The reason that column 2 is referenced instead of column 3 is that
column indexes start with 0, not 1, in Access.

Warm Regards,
Crystal
*
(: have an awesome day
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



trevi wrote:
> Hi,
> I have a combo box on my main form based on a table. Then I have a table in
> the subform that works off another table. They are linked by ID. I linked
> the child / parent and I can go through each record, but when I try to put my
> cursor in the bottom half (subform) it tells me that I can't insert duplicate
> data. I have absolutely no idea why and I was told that I dont need to put
> any VBA code in to make it work. I am really lost. Can you please give me
> some tips?
>
> I tried creating my own combo box from scratch, one from the wizard and one
> which I 'changed' to a combo box and nothing works. Thanks for helping.

 
Reply With Quote
 
strive4peace
Guest
Posts: n/a
 
      29th Dec 2006
you're welcome, Trevi happy to help


Warm Regards,
Crystal
*
(: have an awesome day
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



trevi wrote:
> Thank you !!!!!!
>
> "strive4peace" wrote:
>
>> My guess is either
>>
>> 1. that the RecordSource for the subform includes that table for the
>> main form
>>
>> OR
>>
>> 2. when you set up the structure for the related table, you started by
>> copying the structure for the parent table and didn't remove the Unique
>> index on the parent ID
>>
>> Turn the Indexes window on when you are in the table design
>> from the menu --> View, Indexes
>>
>> and look at what is set up
>>
>> These are just wild guesses because you haven't given enough information
>> to really know what is going on.
>>
>> What is the RecordSource for the mainform? for the subform? What is the
>> structure for your tables?
>>
>> as for setting up a combobox, here is an example of properties that need
>> to be set:
>>
>> *** Combobox Example ***
>>
>> * Under no circumstances should you store names in more than one place.
>> For instance, if you have a People table, define a PID (or PeopleID)
>> autonumber field. Then, in other tables, when you want to identify a
>> person, you can use the key field. One way to do this…
>>
>> Create an autonumber field in the People table -->
>>
>> PID, autonumber
>>
>> then, in the other tables...
>> PID, long, DefaultValue = Null
>>
>> Then, when you want to put data in (which should be done from a form),
>> you can set it up to pick names from a list but store the PID.
>>
>> create a combobox control
>>
>> Name --> PID
>>
>> ControlSource --> PID
>>
>> RowSource -->
>> SELECT
>> PID,
>> LastName & ", " & Firstname AS Fullname,
>> BirthDate
>> FROM People
>> ORDER BY LastName, Firstname
>>
>> BoundColumn --> 1
>>
>> ColumnCount --> 3
>>
>> columnWidths --> 0;2;1
>> (etc for however many columns you have -- the ID column will be hidden)
>>
>> ListWidth --> 3
>> (should add up to the sum of the column widths)
>>
>> if you have a listbox, sometimes you need to make the width .01 more
>> than the sum of the columns to prevent the horizontal scrollbar from
>> appearing.
>>
>> PID will be stored in the form RecordSource while showing you names from
>> another table... a MUCH better and more reliable method.
>>
>> If you want to show other information from your combobox in other
>> controls, you can use calculated fields. For instance
>>
>> textbox:
>> Name --> BirthDate
>> ControlSource --> = PID.column(2)
>>
>> The reason that column 2 is referenced instead of column 3 is that
>> column indexes start with 0, not 1, in Access.
>>
>> Warm Regards,
>> Crystal
>> *
>> (: have an awesome day
>> *
>> MVP Access
>> Remote Programming and Training
>> strive4peace2006 at yahoo.com
>> *
>>
>>
>>
>> trevi wrote:
>>> Hi,
>>> I have a combo box on my main form based on a table. Then I have a table in
>>> the subform that works off another table. They are linked by ID. I linked
>>> the child / parent and I can go through each record, but when I try to put my
>>> cursor in the bottom half (subform) it tells me that I can't insert duplicate
>>> data. I have absolutely no idea why and I was told that I dont need to put
>>> any VBA code in to make it work. I am really lost. Can you please give me
>>> some tips?
>>>
>>> I tried creating my own combo box from scratch, one from the wizard and one
>>> which I 'changed' to a combo box and nothing works. Thanks for helping.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
filter combo box in subform withe a combo box in main form. Mike Microsoft Access Form Coding 0 18th Jan 2010 10:23 AM
requery subform combo afterupdate of main form combo nycdon Microsoft Access Form Coding 5 30th Aug 2009 01:02 PM
Subform that has selectable addresses. Subform based on combo box. lamaine@emailpub.net Microsoft Access Forms 0 14th May 2008 05:49 PM
subform combo to filter based on other subform...technically mainform's other subform records. nospam@thankyou.com Microsoft Access 0 15th Sep 2006 07:51 PM
Requery a subform combo box based on a main form combo box =?Utf-8?B?ZW1pbHk=?= Microsoft Access Form Coding 2 30th Aug 2006 01:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:46 PM.