Help placing code to print record based on textbox value

Liz_I3

Well-known Member
Joined
Dec 30, 2002
Messages
647
Office Version
  1. 2016
Platform
  1. Windows
I have placed the below code in the form's after update event. It works but unfortunately it triggers the print again if the navigation button ( move next or move previous) are used to view that record. Where should I be placing this code so that it will only print the record initially when it is entered.


Private Sub Form_AfterUpdate()
If Me.txtNoErrors > 0 Then
Call PrintError
End If


Thanks
L
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi Just an update I placed the same code above in the After Insert event instead of After Update and now it does only fire on the initial entry. But now where would I put the code so that it would also fire only if the record was changed. I did try it on the After Update and On Current but if would not fire . Same code but I put if me.dirty = true then......

Thanks
L
 
Upvote 0
After update should work. That it fires when you use the navigation buttons suggests something in your form creates updates every time the user goes to the record (whatever the reason).
 
Upvote 0
Same code but I put if me.dirty = true then

with the forms After update event the dirty property will always be false (the record is saved). You need to remove the If statement. You may also prefer to put in the before update depending on what PrintError is doing.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top