FormDataSource.findValue(Int32, String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Finds the specified value in the data source and makes the record that has that value the current record that uses the FormDataSource.findRecord method.
public:
virtual bool findValue(int _field, System::String ^ _value);
public virtual bool findValue (int _field, string _value);
abstract member findValue : int * string -> bool
override this.findValue : int * string -> bool
Public Overridable Function findValue (_field As Integer, _value As String) As Boolean
Parameters
- _field
- Int32
The value to find.
- _value
- String
The value to find.
Returns
true if the value is found; otherwise, false.
Remarks
This method is called when a user clicks FindValue in the shortcut menu on a form control. The findValue method can be overridden on a form data source by right-clicking the Methods node under the data source, pointing to Override Method, and then clicking findValue.
The following example stores the ID of the current record before it tries to modify data. If the update fails, the data source is positioned on the original record.
void clicked()
{
DocuTypeId docuTypeId;
RecId activeRecId;
;
// Store current RecID
activeRecId = docuRef.RecId;
// Open the Document Type dialog.
docuTypeId = smmDocuments::getDocuTypeId(element.args().record());
try
{
ttsbegin;
if (docuTypeId)
{
// Create a new document record
docuRef_ds.create();
docuRef.RefTableId = tableReference;
docuRef.RefRecId = recReference;
docuRef_ds.write();
super();
}
ttscommit;
}
catch
{
// Focus moved back to original record if there is an error
docuRef_ds.executeQuery();
docuRef_ds.findValue(fieldnum(DocuRef,RecId),
int642str(activeRecId));
}
}