Import Error! "There is a Syntax Error"

nvermanverma Member Posts: 396
I am trying to import a PDF. This is the code I have for the import. But when I try to compile it, it give me message saying "There is a syntax error"

I cant seem to find error in this code anywhere. Anyone have any ideas or suggestions what might be causing this problem.

PDFExists := "File Data".HASVALUE;

IF "File Data".IMPORT ('*.PDF', TRUE) =' ' THEN BEGIN
MESSAGE (Text005);
EXIT;
END

IF PDFExists THEN
IF NOT CONFIRM (Text001, FALSE) THEN
EXIT;

CurrForm.SAVERECORD;

Any help will be greatly appreciated. Thanks in advance!

Comments

  • thmartinthmartin Member Posts: 90
    It is probably the missing semicolon after the END statement.
    Thomas Martin
    NAV Developer
  • nvermanverma Member Posts: 396
    I move some of the code around and now it works! It opens a window where I can select a file I want to import. But when I click the Ok button to import it, it doesnt do anything. Anyone have any idea, what might be wrong with the code?
  • matttraxmatttrax Member Posts: 2,309
    It looks correct. It's structured exactly the same as the picture import on Company Information.

    "File Data" is a BLOB in your record?
  • nvermanverma Member Posts: 396
    Yup. I got the code from company information. I just manipulated it a little to fit my needs.

    It is a BLOB. I just have no idea why its not working.

    Now when I click on the Import button it open the window where I can select the file I want to import. But when I select the file and click Ok. It doesnt do anything. Any idea whats going on.

    How do i change all types from BMP image to PDF (Check out the Screenshot, you will know what i mean). Right now its set ot BMP image. Any Ideas or suggestions?

    Screenshot link.
    Problem.png - 0.13MB
  • SavatageSavatage Member Posts: 7,142
    http://msdn.microsoft.com/en-us/library/dd355181.aspx

    Based on your selection, only the appropriate file types are shown.

    For example, if you select Bitmap, only files with the extension .bmp are shown.
    If you select Memo, only files with the extension .txt are shown. I
    f you select User-Defined, all files are shown.
  • nvermanverma Member Posts: 396
    I was able to get the import to work.

    How can i display the name of the file that was imported? I am able to get the name and the path of the file. But i only want to display the name.

    I tried doing it, the following way, but doing it this way displays the import dialoug box twice. I tried setting the TRUE to FALSE.

    "Filename := "File Data".IMPORT ('*.PDF;*.doc;*.docx;*.xls;*.xlxs', FALSE);"

    But I get another the following ERROR message: "The file name *.PDF;*.doc;*.docx;*.xls;*.xlxs' contains a character that cannot be used. Check the file name."

    Any ideas?


    This is what I have so far.


    CALCFIELDS ("File Data");
    IF "File Data".HASVALUE THEN
    FileExists := TRUE;
    Filename := "File Data".IMPORT ('*.PDF;*.doc;*.docx;*.xls;*.xlxs', TRUE);

    IF "File Data".IMPORT ('*.PDF;*.doc;*.docx;*.xls;*.xlxs', TRUE) ='' THEN
    BEGIN
    ERROR(Text005)
    END;

    IF FileExists THEN
    IF NOT CONFIRM (Text001, FALSE) THEN
    EXIT;

    CurrForm.SAVERECORD;
  • nvermanverma Member Posts: 396
    nevermind...i figured it out. Thanks
Sign In or Register to comment.