Save or Update Changes

  • Thread starter Thread starter mattc66 via AccessMonster.com
  • Start date Start date
M

mattc66 via AccessMonster.com

Hi All,

When I make changes to the data on my form which is based on a query, those
changes don't appear on my reports until I have advanced to the next record.
How could I apply those changes without advancing to the next record?

Thanks
Matt
 
You need to requery the recordsource, which could be done many different
ways. You could add a command button to your form, or use the AfterUpdate of
a control, or the LostFocus event of a control, and so on, and so on. It
really depends on what your preferences are (which we don't know)
 
That was what I thought. See below code that I have the Requery. When I run
it I get a message that says: Method or Data member not found. Me.
qryPurchaseOrder_C2.Requery

Private Sub cmdPrntPO_Click()
On Error GoTo Err_cmdPrntPO_Click

Dim stDocName As String
Dim stLink As String

Me.qryPurchaseOrder_C2.Requery

stLink = "[PO_NO]=" & "'" & [PO_NO] & "'"

stDocName = "rptPurchaseOrder_C2"
DoCmd.OpenReport stDocName, acPreview, , stLink

Exit_cmdPrntPO_Click:
Exit Sub

Err_cmdPrntPO_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdPrntPO_Click

End Sub
You need to requery the recordsource, which could be done many different
ways. You could add a command button to your form, or use the AfterUpdate of
a control, or the LostFocus event of a control, and so on, and so on. It
really depends on what your preferences are (which we don't know)
[quoted text clipped - 4 lines]
Thanks
Matt
 
If qryPurchaseOrder_C2 is the recordsource of your form, then all you need is;

Me.Requery
--
_________

Sean Bailey


mattc66 via AccessMonster.com said:
That was what I thought. See below code that I have the Requery. When I run
it I get a message that says: Method or Data member not found. Me.
qryPurchaseOrder_C2.Requery

Private Sub cmdPrntPO_Click()
On Error GoTo Err_cmdPrntPO_Click

Dim stDocName As String
Dim stLink As String

Me.qryPurchaseOrder_C2.Requery

stLink = "[PO_NO]=" & "'" & [PO_NO] & "'"

stDocName = "rptPurchaseOrder_C2"
DoCmd.OpenReport stDocName, acPreview, , stLink

Exit_cmdPrntPO_Click:
Exit Sub

Err_cmdPrntPO_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdPrntPO_Click

End Sub
You need to requery the recordsource, which could be done many different
ways. You could add a command button to your form, or use the AfterUpdate of
a control, or the LostFocus event of a control, and so on, and so on. It
really depends on what your preferences are (which we don't know)
[quoted text clipped - 4 lines]
Thanks
Matt

--
Matt Campbell
mattc (at) saunatec [dot] com

Message posted via AccessMonster.com
 
mattc66 via AccessMonster.com said:
When I make changes to the data on my form which is based on a query, those
changes don't appear on my reports until I have advanced to the next record.
How could I apply those changes without advancing to the next record?

Add a command button which saves the record. In behind the code place

If me.dirty = true then _
docmd.runcommand accmdsaverecord.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
That was to easy.. Thank you it works great!
If qryPurchaseOrder_C2 is the recordsource of your form, then all you need is;

Me.Requery
That was what I thought. See below code that I have the Requery. When I run
it I get a message that says: Method or Data member not found. Me.
[quoted text clipped - 31 lines]
 
mattc66 via AccessMonster.com said:
Hi All,

When I make changes to the data on my form which is based on a query,
those
changes don't appear on my reports until I have advanced to the next
record.
How could I apply those changes without advancing to the next record?

Thanks
Matt

--
Matt Campbell
mattc (at) saunatec [dot] com

Message posted via AccessMonster.com

Save the record explicitly, like this:

If Me.Dirty Then Me.Dirty = False

Then open your report. The record will now display.
 
Me.qryPurchaseOrder_C2.Requery
Is qryPurchaseOrder a query? AFAIK, Forms and Controls have a Requery method
but queries do not. In addition, Requery will reflect new, deleted or
changed records but if you haven't saved changes to the current record (your
original question), I'm not sure those changes will be included. If they are
included it would only be because Access automatically saved the record
first. Its also unlikely that your form will be showing the same record
after a requery unless you specifically move it back.

How about simply saving the record before opening the report?
Docmd.RunCommand acCmdSaveRecord

--
HTH,
George


mattc66 via AccessMonster.com said:
That was what I thought. See below code that I have the Requery. When I
run
it I get a message that says: Method or Data member not found. Me.
qryPurchaseOrder_C2.Requery

Private Sub cmdPrntPO_Click()
On Error GoTo Err_cmdPrntPO_Click

Dim stDocName As String
Dim stLink As String

Me.qryPurchaseOrder_C2.Requery

stLink = "[PO_NO]=" & "'" & [PO_NO] & "'"

stDocName = "rptPurchaseOrder_C2"
DoCmd.OpenReport stDocName, acPreview, , stLink

Exit_cmdPrntPO_Click:
Exit Sub

Err_cmdPrntPO_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdPrntPO_Click

End Sub
You need to requery the recordsource, which could be done many different
ways. You could add a command button to your form, or use the AfterUpdate
of
a control, or the LostFocus event of a control, and so on, and so on. It
really depends on what your preferences are (which we don't know)
[quoted text clipped - 4 lines]
Thanks
Matt

--
Matt Campbell
mattc (at) saunatec [dot] com

Message posted via AccessMonster.com
 
Glad I could help :-)
--
_________

Sean Bailey


mattc66 via AccessMonster.com said:
That was to easy.. Thank you it works great!
If qryPurchaseOrder_C2 is the recordsource of your form, then all you need is;

Me.Requery
That was what I thought. See below code that I have the Requery. When I run
it I get a message that says: Method or Data member not found. Me.
[quoted text clipped - 31 lines]
Thanks
Matt
 
Back
Top