Cant add new record

Directlinq

Registered User.
Local time
Today, 02:48
Joined
Sep 13, 2009
Messages
67
Please Please Please could someone help me.
In my form i have this code that saves a report as pdf using lebans code and files and creates a new record.
The problem is when it gets to the new record bit i get an error.

"Cant use GoToRecord action or method on an object in design view"

I have spent the last 3 hours trying to figure this out.
Help!

Code:
Private Sub Command191_Click()
Dim blRet As Boolean
Dim strWhere As String
Dim strReportName As String
Dim MyPath As String

If IsNull(Me.ClientName) And IsNull(Me.Contents) Then

Exit Sub
End If

If IsNull(Me.ClientName) Then
MsgBox "Please Enter The Name Of The Recipient"
Exit Sub
End If
If IsNull(Me.Contents) Then
MsgBox "Please Enter The Contents Of The Letter"
Exit Sub
End If



DoCmd.Echo False
DoCmd.RunCommand acCmdSaveRecord
'MyPath = "F:\Vatbooks\Letters\"
MyPath = "c:\"
MyFilename = Format("Letter" & " No" & [HeadedPaperID] & " " & [ClientName] & " " & [InvoicedMonth] & " " & [InvoicedYear] & ".pdf")
strReportName = "Headed Paper"
strWhere = "HeadedPaperID = " & [Forms]![HeadedPaper]![HeadedPaperID]

DoCmd.OpenReport strReportName, acViewPreview, , strWhere
Reports(strReportName).Visible = False

blRet = ConvertReportToPDF(strReportName, vbNullString, MyPath & MyFilename, False, False, 150, "", "", 0, 0, 0)

DoCmd.Close acReport, strReportName

DoCmd.Echo True
Me.Requery

DoCmd.GoToRecord , , acNewRec

End Sub

Many Thanks
 
"Cant use GoToRecord action or method on an object in design view"
It means the object with focus is in design view and so cannot go to a record.

Set the focus on the object where you wish to apply the command.
 

Users who are viewing this thread

Back
Top Bottom