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

Save record command before requery

Status
Not open for further replies.

pmo

Technical User
Jan 15, 2001
76
AU
I have a nested sub form (Continuous Form).
In the footer of the form I have a simple calculation that adds all of the costs that are listed in the detail section of the form. Everything works Ok. I want to add a button in the footer called that when clicked requeries the form to enable the calculations. My reason for this is if a user adds a record but doesn't move from that record the calculation has been updated.

So far in the button I have a requery function which tells me I have to save the form before it can run. My code is basic so I am having difficulties doing this.

I have tried:

Private Sub Command20_Click()
DoCmd.Save acDefault
[Forms]![AppointmentF]![AppointmentSubF]![ServiceF].Requery
End Sub

I am not sure how to input the what to save section.

Wayne
 
try
DoCmd.RunCommand acCmdSaveRecord
I would place onexit of the last field in the form [servicef]You will have to make that field required

Hope this helps
Hymn
 
Thanks Hymn that worked for me,
Can I push the frienship a bit further and request more assistance.

I currently have a Form called "AppointmentF" a subform within this called "AppointmentSubF" and another subform within that one called "ServiceF"

From "AppointmentF" I have opened a pop up form called "serviceListF".
From this list the user selects a record then clicks a button that carries out the following.
Goes back to the nested "ServiceF" opens a new form and pastes 2 values from the "SeviceListF"
I am having trouble with the code that says to create a new record.

I have tried this but it can't find the "ServiceF". Do I need to put the full path in? If so How?

Private Sub Command10_Click()
DoCmd.GoToRecord acActiveDataObject, "ServiceF", acNewRec
Forms("AppointmentF")("AppointmentSubF")("ServiceF")("Service") = Forms("ServiceListF")("ServiceListSubF")("Type")
Forms("AppointmentF")("AppointmentSubF")("ServiceF")("SCost") = Forms("ServiceListF")("ServiceListSubF")("Cost")


End Sub


Thanks in anticipation
Wayne
 
Sorry its took so long but I posted this morning and tek tips crashed
First I would create two temp strings temp1, Temp2 and make them public
temp1 = type
temp2 = cost
Private Sub Command10_Click()

openform
DoCmd.GoToRecord , , acNew
XXXXX=temp1
ZZZZZ=temp2


Hope this helps
Hymn
 
Thanks Hymn,

If the form that I want to have a new record open in is a sub, sub form.
What changes would need to be made to the line--
DoCmd.GoToRecord , , acNew

As you can see am in the very early stages of code.
Thanks

Wayne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top