struggling with error on e.mail address

rainbows

Registered User.
Local time
Today, 04:42
Joined
Apr 21, 2017
Messages
428
this is an Acknowledge form. if i select "open ACK" I get the reports below which is correct and you can see the e.mail address in it
yet if i select the buttons " email or create ack pdf i get this e.mail error if i select ok the email will show up as show below yet the e.mail address is not in the pdf file like it was on the "open ack " one below is the code for the file to save as PDF



Thanks for your help

steve


Code:
Private Sub cmdPDF_Click()




  On Error GoTo Err_Handler
    
    Const FOLDER_EXISTS = 75
    Const MESSAGE_TEXT1 = "No current invoice."
    Const MESSAGE_TEXT2 = "No folder set for storing PDF files."
    Dim strFullPath As String
    Dim varFolder As Variant
    
   If Not IsNull(Me.id) Then
        ' build path to save PDF file
       ' varFolder = "C:\Users\User\Documents"
        varFolder = DLookup("Folderpath", "pdfFolder")
        If IsNull(varFolder) Then
            MsgBox MESSAGE_TEXT2, vbExclamation, "Invalid Operation"
        Else
            ' create folder if does not exist
                                    
            varFolder = varFolder & "\" & [Order Details subform]![CustomerName]
            MkDir varFolder
            'strFullPath = varFolder & "\" & ME.CustomerName & " " & Me.Invoicenumber & ".pdf"
          strFullPath = varFolder & "\" & "Ackowledgement number " & " " & Me.id & ".pdf"
            ' ensure current record is saved before creating PDF file
            Me.Dirty = False
            DoCmd.OutputTo acOutputReport, "order acknowledgement", acFormatPDF, strFullPath
        End If
    Else
        MsgBox MESSAGE_TEXT1, vbExclamation, "Invalid Operation"
    End If

Exit_Here:
    Exit Sub
    
Err_Handler:
    Select Case Err.Number
        Case FOLDER_EXISTS
        Resume Next
        Case Else
        MsgBox Err.Description
        Resume Exit_Here
    End Select

End Sub






1666621765763.png






1666621832702.png




1666622058271.png



1666622226137.png

1666622323123.png
 
Almost inevitably, when you get an input box saying "Enter parameter" and it names a parameter, it is because a field in some query is

(a) improperly qualified with regard to where to find it, i.e. in which table OR
(b) is spelled incorrectly with regard to the actual field name in the table's field definitions.

Those two options (qualifying or spelling) make up 99+% of the causes for that behavior. The query's offending field can be in a SELECT clause, a WHERE clause, an ORDER BY clause, or a HAVING clause. OR even a JOIN clause. Anywhere within the query where a name is legal. The named (requested) parameter is the field name in your query that wasn't qualified or spelled correctly.

None of your exhibits show the SQL of your query so that's all I can explain at the moment.
 
We appear to have emailaddress and [e-mail address]?
 
yes , i did see that 2 email address and i dont know how and why. as i only seem to have it in the code / else where it is emailaddress.
but i cannot understand how it shows the e.mail addresss on the first report i did and not on the other 2 as it is the same report. but sending it or saving it

yet as you can see it does select the correct address when sending to e.mail just has not got the e.mail adreess in the report. i did change the e.mail address in the code but made no difference. very confussing



Code:
SELECT IIf([Schedule date] Is Null,[Forms]![sales orders]![NavigationSubform].[Form]![scheduled date],[Schedule date]) AS [date], [Order Details].Sellprice, [Acknwoledge order].id, [Order Details].BatchNo, Orders.[Exchange rate2], [Acknwoledge order].[scheduled date], [buyers name].Tittle, Customers.Currency, [Acknwoledge order].Terms, Orders.CustomerName, [Acknwoledge order].[Exchange Rate 1], [Acknwoledge order].[Sales person], [Acknwoledge order].intcoterms, [FirstName] & " " & [lastname] AS fullname, [Order Details].[Schedule date], [buyers name].[e-mail], Customers.FirstName, [Order Details].OrderQty, [Order Details].Required, Orders.OrderNo, Orders.NCONo, Orders.Received, [Order Details].ProductNo, Products.Pdescription, [Order Details].Price, [Order Details].[Exchange Rate], [price]/[exchange rate2] AS [Unit price], Products.Pdescription, Customers.EMailaddress
FROM ([buyers name] INNER JOIN ([Acknwoledge order] INNER JOIN ((Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerName) INNER JOIN [Order Details] ON (Orders.OrderID = [Order Details].OrderID) AND (Orders.OrderID = [Order Details].OrderID) AND (Orders.OrderID = [Order Details].OrderID)) ON [Acknwoledge order].[NCO No] = Orders.NCONo) ON [buyers name].[buyers name] = [Acknwoledge order].[Sales person]) LEFT JOIN Products ON [Order Details].ProductNo = Products.ProductID
WHERE ((([Acknwoledge order].id)=[Forms]![sales orders]![NavigationSubform].[Form]![id]));
 
Well somewhere you have E-Mail address in a data source, else it would not be asking for it? :(
 
i have found that data source in another old table of which i dont reference anywhere i can see other than the code of which if i change it

but i am confused why will this not error and the second one does

one is opening the report and one is saving it

this one opens it

Code:
Private Sub cmdOpenInvoice_Click()

On Error GoTo Err_Handler
   
    Const MESSAGE_TEXT = "No current ack number."

    If Not IsNull(Me.id) Then
        ' ensure current record is saved
        Me.Dirty = False
        ' open report in print preview
        DoCmd.OpenReport "order acknowledgement", View:=acViewPreview
    Else
        MsgBox MESSAGE_TEXT, vbExclamation, "Invalid Operation"
    End If
   
Exit_Here:
    Exit Sub
   
Err_Handler:
    MsgBox Err.Description
    Resume Exit_Here

this one i want to save to file and no ref to the e.mail address yet it errors
Code:
Private Sub cmdPDF_Click()


  On Error GoTo Err_Handler
   
    Const FOLDER_EXISTS = 75
    Const MESSAGE_TEXT1 = "No current invoice."
    Const MESSAGE_TEXT2 = "No folder set for storing PDF files."
    Dim strFullPath As String
    Dim varFolder As Variant
   
   If Not IsNull(Me.id) Then
        ' build path to save PDF file
       ' varFolder = "C:\Users\User\Documents"
        varFolder = DLookup("Folderpath", "pdfFolder")
        If IsNull(varFolder) Then
            MsgBox MESSAGE_TEXT2, vbExclamation, "Invalid Operation"
        Else
            ' create folder if does not exist
                                   
            varFolder = varFolder & "\" & [Order Details subform]![CustomerName]
            MkDir varFolder
            'strFullPath = varFolder & "\" & ME.CustomerName & " " & Me.Invoicenumber & ".pdf"
          strFullPath = varFolder & "\" & "Ackowledgement number " & " " & Me.id & ".pdf"
            ' ensure current record is saved before creating PDF file
            Me.Dirty = False
            DoCmd.OutputTo acOutputReport, "order acknowledgement", acFormatPDF, strFullPath
        End If
    Else
        MsgBox MESSAGE_TEXT1, vbExclamation, "Invalid Operation"
    End If

Exit_Here:
    Exit Sub
   
Err_Handler:
    Select Case Err.Number
        Case FOLDER_EXISTS
        Resume Next
        Case Else
        MsgBox Err.Description
        Resume Exit_Here
    End Select

End Sub


this one i w
Code:
Private Sub cmdEmail_Click()




    Dim strTo As String
    Dim strSubject As String
    Dim strMessageText As String
   
    Me.Dirty = False
 
   strTo = [Order Details subform].[Form]![E-Mail address]
    strSubject = " Acknowledgement Number " & Me.id
    strMessageText = Me.Firstname & "," & _
        vbNewLine & vbNewLine & _
        "Your latest Acknowledgement is attached." & _
        vbNewLine & vbNewLine & _
        ""


    DoCmd.SendObject ObjectType:=acSendReport, _
        ObjectName:="order acknowledgement", _
        OutputFormat:=acFormatPDF, _
        TO:=strTo, _
        Subject:=strSubject, _
        messageText:=strMessageText, _
        EditMessage:=True
   

End Sub
want to send it to them but still same error i have changed the E-Mail address] to emailaddress but still the same error as it is the e.mail adress in the report thats not working on them 2 buttons yet it is on the first button

thanks
steve
 
Forget about buttons. :(

You need to see what each button, runs what code/query.
One is working with the correct name, the other is not.

YOU need to understand how each works. Only then you can identify where the error is.
If I was you, I would walk though all the steps for each report. That way I should be able to spot where the error is.

Start with the one that works. Make notes if you have to.
 
Found it. the field name was emailaddress but it was called e-mail address in the propertity field name box


thanks for your help
 

Users who are viewing this thread

Back
Top Bottom