Jeremy Campbell
asked on
Trying to run commands on hidden form from another form using vba
Here is what I'm trying but I'm getting the following error at the .DoCmd.GotoRecord,,acNewRe c Line
Here is my code;
DoCmd.OpenForm "frmSendNotify", , , , , acHidden
With [Forms]![frmSendNotify]
.DoCmd.GoToRecord , , acNewRec
.NotifyText = fOSUserName() & " - " & Me.Desc
.docmd.Close
End With
Thanks in advance!
Here is my code;
DoCmd.OpenForm "frmSendNotify", , , , , acHidden
With [Forms]![frmSendNotify]
.DoCmd.GoToRecord , , acNewRec
.NotifyText = fOSUserName() & " - " & Me.Desc
.docmd.Close
End With
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok.. figured out what was causing it to crash although I don't know why.
The line:
Form_frmSendNotify.PublicR ecordMoveN ext
that fired the code;
Public Sub PublicRecordMoveNext() ' it has to be public
DoCmd.GoToRecord acDataForm, "frmSendNotify", acNext
Debug.Print f1, f2
End Sub
for some reason caused it to crash when it was running from the user interface.
I removed that portion of it and added an On Open event to the frmNotify;
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub
I really don't know why that was causing the entire program to crash and why it didn't in programming mode but adding the OnOpen code fixed it.
Thanks for the help!
The line:
Form_frmSendNotify.PublicR
that fired the code;
Public Sub PublicRecordMoveNext() ' it has to be public
DoCmd.GoToRecord acDataForm, "frmSendNotify", acNext
Debug.Print f1, f2
End Sub
for some reason caused it to crash when it was running from the user interface.
I removed that portion of it and added an On Open event to the frmNotify;
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub
I really don't know why that was causing the entire program to crash and why it didn't in programming mode but adding the OnOpen code fixed it.
Thanks for the help!
Welcome!
"I really don't know why that was causing the entire program to crash and why it didn't in programming mode but adding the OnOpen code fixed it."
No use of discussing this here, I dont' have an immediate explanation for such issue. You may open a new question exploring that statement. A required solution is not fixing but explaining why.
You need to upload a sample database recreating the problem.
"I really don't know why that was causing the entire program to crash and why it didn't in programming mode but adding the OnOpen code fixed it."
No use of discussing this here, I dont' have an immediate explanation for such issue. You may open a new question exploring that statement. A required solution is not fixing but explaining why.
You need to upload a sample database recreating the problem.
ASKER
Yeh, I'm just going to leave that one alone.. It's working and that's all I'm concerned about now.. I'll post something else on it if it comes up again and I'm unable to remedy it. :)
Thanks again for your help!
Thanks again for your help!
Welcome!
ASKER
The code appears to work but for some reason when I try the code running my program outside of programming mode access completely crashes when I try to execute it.
Here is a screenshot;
When I run the code in programming mode from access everything runs perfectly.. Going to just try and debug it by eliminating the few extra lines I added in. Here is my code for it;
Me.GenFrom = Me.txtForm
Me.DateSubmitted = Now()
Me.SubmittedBy = fOSUserName()
DoCmd.OpenForm "frmSendNotify", acNormal
Form_frmSendNotify.PublicR
Form_frmSendNotify.UserNam
Form_frmSendNotify.NotifyT
Form_frmSendNotify.DateSen
DoCmd.Close acForm, "frmSendNotify"
DoCmd.Close acForm, "frmEnhancements"