Current record does not show on report, manual refresh

scopes456

Registered User.
Local time
Today, 06:36
Joined
Feb 13, 2013
Messages
88
Good Day, I have a form that when a user fills out the information and select a submit button. It brings up that record in reports in print preview for them to print. The issue i am having when the user enter the information, the report does not show any data until i refresh it. I tried include me.refresh,etc. No luck. I attached the code to make things simpler.


Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
If MsgBox("Do you want to Submit this Contract Form? Clicking No will DELETE ALL ENTERIES,and Log You Off", vbYesNo, "CONTRACT FORM") = vbNo Then
Me.Undo
Cancel = True
Else
If MsgBox("PRINT FORM", vbOKOnly, "CONTRACT PRINT") = vbOK Then
DoCmd.OpenReport "rpt_Contracts_Main", acViewReport, , "[CONTRACT_ID]=" & Me!CONTRACT_ID


End If
End If
End If

End Sub

The reports comes up, but i have to manually refresh it to show the data that was enter.

Thank You for your help
 
Try...

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

     If Me.Dirty Then
      If MsgBox("Do you want to Submit this Contract Form? Clicking No will DELETE ALL ENTERIES,and Log You Off", vbYesNo, "CONTRACT FORM") = vbNo Then
       Me.Undo
       Cancel = True
     Else
    If MsgBox("PRINT FORM", vbOKOnly, "CONTRACT PRINT") = vbOK Then
     DoCmd.RunCommand acCmdSaveRecord
     DoCmd.OpenReport "rpt_Contracts_Main", acViewReport, , "[CONTRACT_ID]=" & Me!CONTRACT_ID
     End If
    End If
    End If

End Sub
 
Gina Whipp, thank for your reply. i try that but when i run the form,i get "Runtime error 2115: The Macro of function set to the BeforeUpdate or ValidationRule property for this field is preventing MS Access from saving the date in the field." When i debug it highlighters the new code docmd.runcommand accmdSaverecord. I was also getting it when i try inserting a refresh command. I dunno if this helps when the user clicks yes the first time, the form does close.
 
Hmm, my fault that line will only work if this action is performed After_Update or on a Command Button. Now, that I read that why is it on the Before_Update event? Seems an odd place to put a Print Report action. What exactly are you trying to do?
 
I am a bit new to vba, I wanted to have my form only save a record after a user enter all data and select a submit button ( which just command the form to close.)

I saw i can use this code in the Before_Update event -
If Me.Dirty Then
If MsgBox("Do you want to Submit this Contract Form? Clicking No will DELETE ALL ENTERIES,and Log You Off", vbYesNo, "CONTRACT FORM") = vbNo Then
Me.Undo
Cancel = True

Using that code, solves that problem, i figure to have the record the user just enter when it save to come up in the report so they can print it, that is why i try adding

"Else
If MsgBox("PRINT FORM", vbOKOnly, "CONTRACT PRINT") = vbOK Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "rpt_Contracts_Main", acViewReport, , "[CONTRACT_ID]=" & Me!CONTRACT_
 
Oh okay, well not the place to put it. You would really need a Print Form Command Button OR you could ask the question in some After_Update event of some field but you can't really ask in the Before_Update because it hasn't actually *saved* yet.
 
GinaWhipp Thank You very much, i use an After_Update event, works perfect
 

Users who are viewing this thread

Back
Top Bottom