Private Sub Command44_Click()
For n = 1 To Forms!BuildMaster!RepeatTime
DoCmd.OpenQuery "BuildMaster_CopyLine"
Next
Me.RepeatTime = 1
Me.CopyLine = False
DoCmd.Requery
End Sub
Looking for some help with my code above. It seems buggy.
I'm not a VBA guy, but am learning. What I'm doing, is I have a build schedule form for our facility.
When we receive new orders, at times, we can copy another order, and then update the fields where the info changes when we receive that info.
I can run this and it works, but not always succcessfully. I have a check box on the line, and when checked, we can enter into a text box, [RepeatTime], the number of times to copy the line if we have more than one order, and then click a button which runs the below code.
First issue, it only works, if [RepeatTime] is greater than 2. If I try to copy 1 line, it will not work.
Second issue, it works a few times, but then stops. I have to remove:
Me.RepeatTime = 1
Me.CopyLine = False
DoCmd.Requery
and run the code again, and then put the above code back in, and it will work again, several times, then stop again.
I'm not sure how to modify it to get it to work again. The lines I'm having to remove, put the user input values back to the default values and requerys the form, so it refreshes and shows the new lines. I feel these are pretty important to keep, and know there's a way to do it. Just struggling on what I'm missing... I know this is almost barbaric coding, so any help is greatly appreciated!
Thank you!