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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get the subform values to update?

Status
Not open for further replies.

seawave

Technical User
Oct 21, 2002
30
US
I have a main form and 2 subforms. When testing the subforms as standalone forms the values update and the textboxes return to null for the next entry. However, when
I enter data values on the subforms, as a part of the main form, the subform values will not update and return a null value when I click my AddNew button on the subform. I get a run time error 2450 -"MS Access cant find the form WorkActivity as referred to in the expression".
The name of my main form is "Existing Ring Diagram". The 1st subform name is "WorkActivity".
I've been working with this for a while, but can not see the error of my ways.
I also have a relationship between the main form and the subform.
Any help would be appreciated.
Thank you.
 
Hi

Do you by chance have code of the form Forms!WorkActivity anywhere in your main form or subform? Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Ken,
In my subform AddNew code I have the code:
Set frm = Forms!WORKACTIVITY
I do not have any code referencing "WorkActivity" in my
main form (Existing Ring Diagram).
This is the code I have in the subform WorkActivity in the AddNew command button:
Sub AddNew_Click()

Dim rst As DAO.Recordset
Dim frm As Form
Set frm = Forms!WORKACTIVITY
Set rst = CurrentDb.OpenRecordset("WA", dbOpenDynaset)
rst.AddNew
rst!DATESUB = frm.DATESUBtext
rst!FT = frm.FTtext
rst!WANOID = frm.WANOIDtext
rst!RINGID = frm.RINGIDtext
rst!CABLENAME = frm.CABLENAMEtext
rst!INSVCDATE = frm.INSVCDATEtext
rst!SUBMIT = frm.SUBMITtext
rst!JOBSUM = frm.JOBSUMtext
rst.Update

frm.DATESUBtext = Null
frm.FTtext = Null
frm.WANOIDtext = Null
frm.RINGIDtext = Null
frm.CABLENAMEtext = Null
frm.INSVCDATEtext = Null
frm.SUBMITtext = Null
frm.JOBSUMtext = Null

Set frm = Nothing
Set rst = Nothing


End Sub

Thanks.
 
Hi

Is this were you get the error, Forms!WorkActivity expects the form WorkActivity to be open, but a sub form is not open in its ownright. This would explain why it works when you run the subform, stand alone

remove the line, Set frm = Forms!WORKACTIVITY
and use me! in place of frm Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top