Jump to content

Finding based on user input, not pre-defined find


This topic is 7241 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I need to perform a find that will find a record that meets two criteria. One of the criteria is static, for all cases of the find to be performed. The other criteria is for a certain ID number. I have a layout were the user types the desired ID number in a field (I have set it up as a global field). When they click a button, it runs a script that should do a few things among which it should perform a find for records with the ID number they request. How do you do this type of find? The only finds in scripts I know how to do are pre-defined find criteria.

Also, is there a function I can call to see how many records are in the found set....to make sure the found set contains one and only one record?

Thank you!

Link to comment
Share on other sites

I use a similar type of find for some of my reports. In mine I usually jump right into find mode without using a global for the ID. This is how it works:

Go to Layout [ Find ]

Enter Find Mode [ Restore ] //Restore predefined criteria

Go to Field [ "ID" ]

Pause/Resume Script [] //Wait for user input

Set Error Capture [On] //supress no records found dialog

Perform Find []

If [ Status(CurrentFoundCount) = 0 ]

Show Message [ "No records found." ]

Go to Layout [ original layout ]

Halt Script

End If

If [ Status(CurrentFoundCount) = 1 ]

Go to Layout [ Form View ]

Else

Go to Layout [ List View ]

...

End If

If you want to require user input in a field, you might use a loop or recursion (or both):

Go to Layout [ Find ]

Enter Find Mode [ Restore ]

Loop

Go to Field [ "ID" ]

Pause/Resume Script [] //Wait for user input

Exit Loop If [ "ID" ]

End Loop

Set Error Capture [ On ]

Perform Find []

If [ Status(CurrentFoundCount) = 0 ]

Perform Script [ Subscripts, "Find Script" ] //Run the find again

Exit Script

End If

...

If you want, you can use globals to gather user input. But you can't enter globals while in Find Mode. You could gather the info in Browse Mode, then Enter Find Mode and use Set Field to set the corresponding find criteria.

Link to comment
Share on other sites

This topic is 7241 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.