Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble Adding Records to Form 2

Status
Not open for further replies.

JOEYB99

Technical User
Jul 9, 2008
121
CA

I am using Access 2007 and have a form that was primarily set up for viewing and editing data in a table. I have a combo box - from an unbound control - that searches and displays records based on a field called Cost Code. It is not the primary key for this table.

Now I want to give the user the capability to add records for a given (valid) cost code. That is, they will select a cost code and display all records for it. Then they can add more records if they like.

But when I add data for a new record I get a blank cost code value when I go into the table. Why is that?

How can I get this field to populate the cost code value automatically when I am creating a new record?
 
I'd set the DefaultValue property of the cost code control to something like this:
=[Forms]![name of forms]![name of combo]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV.

I tried that but it did not work. Can you suggest anything else?

 
JOEYB99,
Can you provide us with more information about your control names and default value properties?

BTW: did you give PHV a star? A star isn't typically awarded until the thread is resolved. PHV's answer should be adequate and correct but we have no idea how you attempted to implement it.

Duane
Hook'D on Access
MS Access MVP
 
Okay Dhookom.

The table is called tblTransactionsWorkFile, and the form is called frmTransactionsWorkFile.

The Record Source property for the form is set to tblTransactionsWorkFile. The Data Entry property of the form is equal to No, and the Allow Additions property of the form is set to Yes. My goal is to have the user view/edit data as well as new records.

The field in the table that I am having trouble when creating new records is called CostCode and it does not have a default value in tblTransactionsWorkFile.

The unbound control is called cmbBxCostCode. It's Row Source property is a query that selects distinct values of cost codes from tblTransactionsWorkFile.

I tried setting the Default Value property of this control as per PHV but it did not work. That is, the cost code field in the table is still coming up blank after I manually input data to create a new record.

Should I be doing something with the After Event Update property of the form?



 
I believe what PHV was suggesting is you need to have a control on the form bound to CostCode and set the default value property to:
Default Value: [cmbBxCostCode]

I don't think you need an "=" sign.


Duane
Hook'D on Access
MS Access MVP
 

That worked! It makes sense too.

Problem solved.

Thank you Dhookom...and PHV.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top