A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Forms with Lookup problem



 
 
Thread Tools Display Modes
  #1  
Old August 16th, 2004, 04:01 PM
ahuntertate
external usenet poster
 
Posts: n/a
Default Forms with Lookup problem

I am new to Access Development I am trying to build a 'simple' form that will
allow me to add records to my log table , display the category of a record by
displaying the Category name for the category ID in the Log table. I also
need to change the category ID in the Log table by having the user select the
category name for a drop down list. I tried this with a form based on a
query that displays the Category name in a combo box but I get errors when I
try to select a different row in the combo box. The error tells me that I am
creating a duplicate value. I think that it is trying to add a new row in my
category table.


Here is what I have setup

Table Category
CategoryID Autonumber Primary Key
Categoryname text(50)


Table Log
ID Autonumber Primary Key
CategoryID Fk to Category table
LogDate Date
Comments

Query vw_log

SELECT Category.CategoryName, Category.CategoryID AS Cat_ID, tbl_Log.WLID,
tbl_Log.CategoryID AS WL_CatID, tbl_Log.LogDate,tbl_WorkLog.comments
FROM Category INNER JOIN tbl_Log ON Category.CategoryID = tbl_Log.CategoryID


  #2  
Old August 16th, 2004, 04:42 PM
Sandra Daigle
external usenet poster
 
Posts: n/a
Default

I'm guessing that since your query includes CategoryID from both tables you
probably have the combo bound to the CategoryID from the Category table. You
really don't need to join to the Category table in your Recordsource query.
Change the query to a simple select query from the log table. Then make sure
to check the ControlSource of the CategoryID to verify that it refers to the
CategoryID from the Log table. The beauty of a combo box is that it allows
you to display the information from the related table (Category) without
joining to it in the Recordsource.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


ahuntertate wrote:
I am new to Access Development I am trying to build a 'simple' form
that will allow me to add records to my log table , display the
category of a record by displaying the Category name for the category
ID in the Log table. I also need to change the category ID in the
Log table by having the user select the category name for a drop down
list. I tried this with a form based on a query that displays the
Category name in a combo box but I get errors when I try to select a
different row in the combo box. The error tells me that I am
creating a duplicate value. I think that it is trying to add a new
row in my category table.


Here is what I have setup

Table Category
CategoryID Autonumber Primary Key
Categoryname text(50)


Table Log
ID Autonumber Primary Key
CategoryID Fk to Category table
LogDate Date
Comments

Query vw_log

SELECT Category.CategoryName, Category.CategoryID AS Cat_ID,
tbl_Log.WLID, tbl_Log.CategoryID AS WL_CatID,
tbl_Log.LogDate,tbl_WorkLog.comments
FROM Category INNER JOIN tbl_Log ON Category.CategoryID =
tbl_Log.CategoryID



 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Most likely Lookup -formula problem John Doe Worksheet Functions 5 June 13th, 2004 10:40 PM
Lookup problem foilprint0 Worksheet Functions 1 May 26th, 2004 11:35 AM
Lookup fields - what's wrong with them? NATHAN SANDERS New Users 2 May 4th, 2004 10:51 AM
Matching / lookup problem Nick Worksheet Functions 3 January 13th, 2004 07:26 AM


All times are GMT +1. The time now is 03:45 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.