WalterInOz
Registered User.
- Local time
- Tomorrow, 04:38
- Joined
- Apr 11, 2006
- Messages
- 93
Hi all,
I have a frm (frmmain) that holds a subfrm (subControlIN_table) in wich incoming messages (correspondence about projects) are stored. To retrieve a message I click on the record selector and a new form (frmIN) opens that displays the message and further details. This works fine. A problem arrises when I'm trying to add a new correspondence record in the subform. I've made a button on frmmain with this code behind it:
Private Sub btnAddIN_Click()
Dim StrMsg As String
Dim intRespons As Integer
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmMain"
DoCmd.Save
StrMsg = "You are about to add a Received Message to the project: " & vbNewLine & " " & vbNewLine & Me!WorkingTitle & " " & vbNewLine
StrMsg = StrMsg & " " & vbNewLine & "Continue?"
intRespons = MsgBox(StrMsg, vbInformation + vbYesNo + vbDefaultButton2, "Store received message for this Project")
If intRespons = vbNo Then
DoCmd.RunCommand acCmdClose
Exit Sub
End If
If intRespons = vbYes Then
stDocName = "frmIN"
stLinkCriteria = "[ProjectID]=" & "'" & Me![ProjectID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
End If
With Forms!frmIN
.WorkingTitle = Me.WorkingTitle
.SFNumber = Me.SFNumber
.ProjectID = Me.ProjectID
End With
End Sub
I expected this to open a blanc record of frmIN but it doesn't. I cannot find the mistake. I get this error message: Run-Time error 2501 the OpenForm action was cancelled. In the code page this line is high-lighted: DoCmd.OpenForm stDocName, , , stLinkCriteria
So I suppose that's where the problem lies, but could be wrong?
Help would be appreciated.
Thanks,
Walter
I have a frm (frmmain) that holds a subfrm (subControlIN_table) in wich incoming messages (correspondence about projects) are stored. To retrieve a message I click on the record selector and a new form (frmIN) opens that displays the message and further details. This works fine. A problem arrises when I'm trying to add a new correspondence record in the subform. I've made a button on frmmain with this code behind it:
Private Sub btnAddIN_Click()
Dim StrMsg As String
Dim intRespons As Integer
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmMain"
DoCmd.Save
StrMsg = "You are about to add a Received Message to the project: " & vbNewLine & " " & vbNewLine & Me!WorkingTitle & " " & vbNewLine
StrMsg = StrMsg & " " & vbNewLine & "Continue?"
intRespons = MsgBox(StrMsg, vbInformation + vbYesNo + vbDefaultButton2, "Store received message for this Project")
If intRespons = vbNo Then
DoCmd.RunCommand acCmdClose
Exit Sub
End If
If intRespons = vbYes Then
stDocName = "frmIN"
stLinkCriteria = "[ProjectID]=" & "'" & Me![ProjectID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
End If
With Forms!frmIN
.WorkingTitle = Me.WorkingTitle
.SFNumber = Me.SFNumber
.ProjectID = Me.ProjectID
End With
End Sub
I expected this to open a blanc record of frmIN but it doesn't. I cannot find the mistake. I get this error message: Run-Time error 2501 the OpenForm action was cancelled. In the code page this line is high-lighted: DoCmd.OpenForm stDocName, , , stLinkCriteria
So I suppose that's where the problem lies, but could be wrong?
Help would be appreciated.
Thanks,
Walter