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!

Data Populating Table but Not Saving On Form

Status
Not open for further replies.

MelF

Technical User
Oct 26, 2000
81
0
0
US
Hello everyone. Current dilemma: I have a form that I enter data into. When I exit the form the data is saved to the appropriate table; however, when I go back into the form the data is gone. Why is this data not being saved to the form, but it is saved in the table??

I'll call the form in question Form II. You access Form II by a command button on Form I. Upon accessing Form II, I want Form II's displayed record to match the record on Form I. (The field CustomerID is a common field on both forms, and the "link".) The forms are linked fine. (Form II displays the same CustomerID as FormI), I enter the data, I close the form, and when I go back into the record, the only field data that shows up is the Customer ID. (The CustomerID is from Form I, and I have the criteria:
[forms]![Site Information Form]![CustomerID]in the CustomerID field on the Form II query - To tell the form to pull this field's value's off of the main form) So - Why is this the only field I can see when I go back into the form?

Also - I have the Data Entry set to No.

Thanks!!
 
Hi,
are the controls on form 2 bound to the table? do you have any code that runs as you exit the form to save the data or is it done automatically?
If it is then it could be that it is taking you setting the value in the CustomerID field as an indication that you want to add a new record. What you want to do instead is open the FormII and apply a filter to only show the one record you're interested in.

Code:
DoCmd.OpenForm "FormII", acNormal, , [CustomerID] = Forms![Site Information Form]![CustomerID], acFormEdit, acWindowNormal
If you modify the code for the button on form I so that the line that opens form II is similar to the code above (the CustomerID] = Forms![Site Information Form]![CustomerID] part is the important part) this will open the new form and only display the record where the IDs match.
Richard
 
Keep in mind that data displayed in a form is only a visual representation of data saved in an underlying table (yeah, I know, there are some exceptions).

You don't save input to a form, you save it to an underlying table. If you can't then get the form to redisplay the saved data, you've got a form problem-most likely you're not pointed at the correct record.

Not knowing exactly where you're going with this, suggest that you open the Northwind database and look at the Orders form, and its Orders Sub Form. This should give you some ideas on how to setup your form/subform relationship.
 
Thanks everyone for your suggestions.

RICHARD - I'm confused on where I should put the string of code you mentioned:

DoCmd.OpenForm "FormII", acNormal, , [CustomerID] = Forms![Site Information Form]![CustomerID], acFormEdit, acWindowNormal

In the command button that opens Form II, or in Form II itself??

Thanks!
 
RICHARD - I put the following code:

DoCmd.OpenForm "Reimbursement Subform", acNormal, , [CustomerID] = Forms![Site Information Form]![CustomerID], acFormEdit, acWindowNormal

into the code for the command button. It keeps asking saying "expression expected". Is this code not right?

Thanks!
 
Hi Mel,
Sorry about that the code seems to have been corrupted when I posted it should read:
DoCmd.OpenForm "Reimbursement Subform", acNormal, , "[CustomerID] = Forms![Site Information Form]![CustomerID]", acFormEdit, acWindowNormal

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top