Reputation: 277
I'm entering data by using a query on a subform. I want to auto populate a job number to each new line I add to that subform.
tbl_Jobs
[Job_ID] <Primary Key
JID1001
JID1002
JID1003
tbl_Job_Tasks
[ID Auto][Job_ID][Task]
1 JID1002 TASK1
2 JID1002 TASK2
3 JID1002 TASK3
4 JID1001 TASK1
Here's my query at the most basic level...
SELECT tbl_Job_Tasks.[Job_ID], tbl_Job_Tasks.[Category], tbl_Job_Tasks.[Task]
FROM tbl_Job_Tasks
WHERE (([Job_ID]="JID1002"));
What I want to be able to do is hide the Job_ID column and have it auto populate for the user if they decide to enter a new task for their Job. Currently if I enter a new task I have to specify the Job_ID to use. This query is being used on a sub form that pulls its Job_ID from the parent form, so in a perfect world the end user would not have to re-enter the Job_ID.
Is this possible?
Thank you,
Upvotes: 0
Views: 241
Reputation: 277
Just to sum up the solution.
After that, the field will update automatically when entering a new row.
Upvotes: 0
Reputation: 1626
If the subform is linked to the parent form correctly (Using the Link Master/Child Fields property) the child records foreign key (in your case tbl_Job_Tasks.Job_ID) should be filled out automatically.
You shouldn't even need the query unless you are filtering the sub forms records in some odd way.
Edit - Have a look here http://www.access-diva.com/f2.html for a solution to your unbound problem.
Upvotes: 1