Filter Form Data with Date Range and info the result

Hi all,

I have a form with one table as its datasource. There is a grid on the form with some columns. Above the grid, I have inserted two DateEdite controls with Labels as From Date and To Date. The DateEdit controls have EDT of TransDate. Besides these, I have a button.

I want to filter the data on the basis of selected date range and then show the result in an info log on button click.

Please help, How can I do that.

Form name is SalesOrderDownload. Table used as datasource of the form is named as SalesOrderDownloadTable. It is a custom table.

Some of the fields which I want to show in an info log are as follows : Customer Account, SalesOrder Number, Amount, DateUploaded

If I understand it correctly, the button should do two separate things:

  1. Filter a data source
  2. After the data source is filtered, it should iterate all records and put some information to infolog.

Let’s focus on the first thing first.

Unfortunately you forgot to tell us which exactly part you need a help with. For example, maybe you don’t know how to work with query ranges at all. Or maybe you know that and explaining it would be a waste of time for both of us.

Let me assume that you know the basics and you just don’t you how to apply a range. Also, I’ll assume that you want to filter a single field, which I’ll call Field1. If so, then you can use queryRange() method.

Like this:

QueryBuildRange field1Range = salesOrderDownloadTable_ds.queryBuildDataSource().addRange(fieldNum(SalesOrderDownloadTable, Field1));
field1Range.value(queryRange(FromDate.dateValue(), ToDate.dateValue()));

Regarding the second part, let’s assume that you’re familiar with info() and you know how to work with table fields, but you don’t know how to iterate the records. You have two options. You can either iterate data loaded to the data source (using salesOrderDownloadTable_ds.getFirst() and getNext()), or execute the query once more with QueryRun class.

I would have given you a much more specific answer if you explained what you actually need from us. Please remember that when asking next time.

Thank you very much for the reply Martin.

Actually, I forgot to mention that the two DateEdit controls are unbound.

I needed help with both of these parts.

  1. Filter a data source
  2. After the data source is filtered, it should iterate all records and put some information to infolog.

OK. I understand the first part except for this (FromDate.dateValue(), ToDate.dateValue()) ??? I assume FromDate and ToDate are names of both DateEdit controls. But as I mentioned, they are unbounded so, will FromDate.dateValue() work correctly here ??

Further, can you please explain in detail both options using which I can iterate through the records.

Lastly, Thank You very much for answering my question. I am going to verify the first answer now, and will also verify second one once you respond to it as well.

Yes, it’ll work for onbound fields as well. They’re references to form controls. Just use names of your controls and make sure they have AutoDeclaration property set to Yes.

What kind of details do you want me to give you about iteration and why do you want me to cover both? Don’t you rather want to pick one, try it and if you run into a problem, explain the problem to us? I suggest that you should try getFirst()/getNext() methods - it should be quite obvious what they’re for.

Thank you very much Martin.