combobox not working on the form (1 Viewer)

sibbbra

Member
Local time
Today, 14:54
Joined
Feb 11, 2022
Messages
78
hi
combobox not working on the form.
The attached Db has a form customers. I cant enter anything. Any help plz !
 

Attachments

  • My DB.accdb
    764 KB · Views: 56

June7

AWF VIP
Local time
Today, 05:54
Joined
Mar 9, 2014
Messages
5,493
It is bound to Type_ID autonumber field from Customer_Type table. Cannot enter data into autonumber field. This field is automatically populated by Access.

Set form RecordSource to Customers table, not query.

Then bind combobox to Type_ID field in Customers.

Set combobox RowSource to: SELECT Type_ID, Type_Name FROM Customer_Type ORDER BY Type_Name;

This is why it is not a good to use exact same field name in multiple tables.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:54
Joined
Feb 19, 2002
Messages
43,485
There is no reason in this case to include the type table in the query. There is only one field in the table other than the PK therefore, the form's combo will show the only field in the lookup table anyway. When you include the lookup table in the query, it is because there are multiple data columns you want to display and the combo box can only show one of them.

The RecordSource query would work fine with the join but ONLY if you select the correct column. You need to bind the Type_ID in the Customers table to the combo, NOT the PK from the Customer_Type table. Your form is NOT changing the Type_ID in the type table, it is changing the type_ID (Foreign key) in the Customers table. When you join tables in a query, you always select the FK half of the pair, not the PK half. You NEVER need to select both and selecting both just leads to confusion.

If you are creating a RecordSource query for a report rather than the form, then, it makes sense to include the lookup table with a join so you can display the lookup value using a textbox rather than a combo. On a form, you are displaying the lookup value using a combo so there is no need to join to the lookup table in the RecordSource query.

I disagree with June regarding naming standards. It is much easier to see the relationships if both the PK and the FK have the same name whenever possible (they can't always). If you prefer them to be different, an acceptable solution is to suffix the FK with "_FK". So the name in Customer_Type would be Type_ID and the name in Customers would be Type_ID_FK.

I know it all seemed easier when you were using table level lookups, but once you understand the concept of the combo/listbox, you'll be better off without the table level lookups.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:54
Joined
May 7, 2009
Messages
19,246
Need to set to All ACcess Objects Arnel. For some strange reason the O/P only had Tables?
thanks. now i see the form.
to the OP, remove the Customer_Type.Type_ID from your query ("Customers Names" query) or
entirely remove customer_type table, then it will work.
 

Attachments

  • My DB.accdb
    1.2 MB · Views: 47

Users who are viewing this thread

Top Bottom