Hey all this is my first post here but I have found many of my answers to google searches on this forum so hopefully you can point me in the right direction!
I have a linked form setup where a person enters a due date and the number of weeks it will take to accomplish. A macro subtracts the number of weeks from the due date to determine the start date, if the start date is earlier than date() an email is sent with the offending record to alert the correct people. my problem is that the form data isn't being picked up by the macro until I do a requery of the form. when I requery the form the form goes back to the first record. I have tried to make a requery vba code that puts the focus back on the correct record number but I can't seem to get it to utilize the "CurrentRecord" function. if I manually enter the correct record number my code and macro work correctly. when I try to set my long variable = Currentrecord it doesn't have a value. I get an error when I try to do Me.currentrecord as well.
here is my VBA code, when I replace the "2306"(my test record) with currentrecord I get nothing. it's like it's not recognizing I have a form open.
Public Function test()
Call bRecalc
End Function
Public Sub bRecalc()
Dim recordn As Long
recordn = 2306
DoCmd.Echo False
DoCmd.Requery
DoCmd.GoToRecord acDataForm, "process development1a", acGoTo, recordn
DoCmd.Echo True
recordn = 0
End Sub
my macro is triggered by the "after update" in the text box. it runs a query that updates the form data.
I have a linked form setup where a person enters a due date and the number of weeks it will take to accomplish. A macro subtracts the number of weeks from the due date to determine the start date, if the start date is earlier than date() an email is sent with the offending record to alert the correct people. my problem is that the form data isn't being picked up by the macro until I do a requery of the form. when I requery the form the form goes back to the first record. I have tried to make a requery vba code that puts the focus back on the correct record number but I can't seem to get it to utilize the "CurrentRecord" function. if I manually enter the correct record number my code and macro work correctly. when I try to set my long variable = Currentrecord it doesn't have a value. I get an error when I try to do Me.currentrecord as well.
here is my VBA code, when I replace the "2306"(my test record) with currentrecord I get nothing. it's like it's not recognizing I have a form open.
Public Function test()
Call bRecalc
End Function
Public Sub bRecalc()
Dim recordn As Long
recordn = 2306
DoCmd.Echo False
DoCmd.Requery
DoCmd.GoToRecord acDataForm, "process development1a", acGoTo, recordn
DoCmd.Echo True
recordn = 0
End Sub
my macro is triggered by the "after update" in the text box. it runs a query that updates the form data.