Data type conversion problem

SoloperSoloper Member Posts: 102
Hi all;

I have a form and it contains only a textbox and a command button. I ask user to enter a date into the textbx then press the button.

After that I want to filter G/L Entry table by this date with the following line;

SETRANGE("Posting Date", CurrForm.txtPostingDate);

I wrote it down into command OnPush trigger of the button.

When I try to compile I get the following error :

Type conversion is not possible because 1 of the operators contains an invalid type

Date:=Control

I see the meaning of the error. But how can I compare or match a table field with the value of a form control?

Thanks so much.

Answers

  • kapamaroukapamarou Member Posts: 1,152
    You declare a global variable of type Date. Then you bind the textbox to the variable using Source Expression from the properties of the control. Finally:


    glEntry.SETRANGE("Posting Date",MyGlobalTextVariable);
  • DenSterDenSter Member Posts: 8,305
    Soloper wrote:
    SETRANGE("Posting Date", CurrForm.txtPostingDate);
    I see the meaning of the error. But how can I compare or match a table field with the value of a form control?
    To elaborate a little.... you use "CurrForm.txtPostingDate" as the parameter for your SETRANGE, which it looks like is the name that you gave to the textbox. The textbox itself is not a datatype, it's a control on the form. It must have a variable as its SourceExpr. If you use the variable in your SETRANGE statement, you should be alright.

    You can use a data type 'Date' but that won't allow you to enter a datefilter. I would probably use a text type variable if I needed to be able to enter filters instead of single date values.
  • SoloperSoloper Member Posts: 102
    The situation which explain Den, I used a text type variable and It works fine.

    Thank you kapamarou and Den for the detailed replies.
  • kinekine Member Posts: 12,562
    Soloper wrote:
    The situation which explain Den, I used a text type variable and It works fine.

    Thank you kapamarou and Den for the detailed replies.

    Rather use the Date type variable instead text variable... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,305
    kine wrote:
    Rather use the Date type variable instead text variable... ;-)
    If you want to enter a date formula into the textbox, a date type variable is not enough.
  • kinekine Member Posts: 12,562
    Yes, but it was not specified, Soloper is talking about date. In case of filter, text is ok, but I will use SETFILTER instead SETRANGE... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,305
    Right if they need a single date only, then I would also use a date type variable, and SETRANGE.
  • southindiansouthindian Member Posts: 247
    I have a type conversion problem. i got a report sent from my head office.... it is a label printing report... when i imported and tried to compile, am getting type conversion error.

    Microsoft Business Solutions-Navision
    Type conversion is not possible because 1 of the operators contains an invalid type.

    Text := VOID

    OK



    In that there is a coding line which is given below

    Addr[1][1] := PrintBarCode.ParseRequest(ICR."Cross-Reference No.");

    when I try to compile it throws the error and the cursor blink at this code only.


    ADDR[1][1]is defined as text[250].

    Printbarcode ====> NAv Comm (Codeuint)

    there the cross reference no. is passed and get converted into barcode number....


    can any body tell what is need to be done.....
  • kapamaroukapamarou Member Posts: 1,152
    You should post this as a new topic. The original one is closed...

    The Addr[1][1] looks suspicious.

    How is it declared? Have you tried Addr[1,1]?
  • southindiansouthindian Member Posts: 247
    yes... i had tried with that also......... but same tyoe conversion error...
Sign In or Register to comment.