Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locate Record

Status
Not open for further replies.

kfenner

Technical User
Apr 6, 2003
52
US
Last question, at least for awhile, I promise!

When you are viewing a table in form view, you can go to a field, use ctrl-z and get a box to type in a value, then it will locate and display that record in the form. I want the user to be able to query a specific field, by using a button to bring up an appropriate dialogue box or something similar. Can ya help?
 
kfenner,

Under object explorer for your button double click on the pushbutton method and type in the following between method and endmethod

method pushButton(var eventInfo Event)
menuAction(MenuRecordLocateValue)
endmethod

This will have the desired effect. The same can be done with the button experts along with a host of other goodies.

Whenever you have a question like this try searching first of all through the postings as I seem to remember answering this question before!!...... <g>

You might also want to have another button, called FIND NEXT
which will find the next occurance of the value. Use the following code:

method pushButton(var eventInfo Event)
menuAction(MenuRecordLocateNext)
endmethod

Trust this helps.

Regards,

Lewy
 
Well, I did search the forum, and I did see your previous post regarding this question. I asked it again, in a bit of a different way because I needed more information. If I do what you describe above, when I try to use the button, I get &quot;Active object is not a field or has a value that cannot be searched&quot;. Obviously, something is missing. I don't know how to tell it what field I want searched, so the user can then input a value to search for. You have to understand, I am a novice learning on my own. What I would really like to do, is have this on the &quot;launcher&quot;, so a user can open the client form on the record they are looking for, instead of having to open the form, then search for the record. I would have to make the search button on a form of it's own to do this, and I have no clue how to go about it. I tried it, but it won't open the client form.

Also, you mention the &quot;button expert&quot;. If it is here, I sure can't find it. Could you give a bit more detail on how to access this feature.

Thanks.
 
kfenner,

Try changing the code to:

method pushButton(var eventInfo Event)
active.menuAction(MenuRecordLocateValue)
endmethod

This will do the locate on the active field. Is this what your are trying to do, I'm not so sure from your original post.

Perrin


 
I tried this and got the same error message. Let me try to explain it another way. If you are viewing in form view, say I am in the &quot;Client&quot; field, I can use ctrl-z and get a box to type in a value, then the record that matches that value will appear in the open form. I want to do the exact same thing, except I want to use a button the user can use, instead of having them use the ctrl-z command. I would prefer to limit the use of the button to one specific field, namely the &quot;client&quot; field, so that no matter what field you are in, if you use the button, you will get the search and locate box for the &quot;client&quot; field value.

As I said in my earlier post, I really would like to have this feature on the &quot;launcher&quot; so a user could open the table in form view to the specific record they are looking for, instead of opening the form, then searching. But, I think if I try it this way, it is going to open in an answer table, which will be deleted when closed. I want it the record to open in form view, and be editable so that it updates the table and the edits don't just disappear when the form is closed.

Gees, this is hard to explain this way. I know I have seen how to do this somewhere, but can't find where it was.
 
Here is a very basic example of some code that will pop up a window for the user to enter a customer number and will locate the record.

var
clientNum number
endvar

clientNum.blank()
clientNum.view(&quot;Enter Client Number&quot;)

if clientNum.isBlank() = false then
if not locate(&quot;Client #&quot;,cleintNum) then
MsgStop(&quot;Error&quot;,clientnum.string()+&quot; &quot;+&quot;Is Not a Valid Number&quot;)
endif
endif

If you want to use this to open a form and move to the record you should use a tcursor and locate the customer on the tcursor and use the moveToRecord() function or setRange() on the form.

something like this

var
clientNum number
tc tcursor
f form
endvar

custNum.blank()
custNum.view(&quot;Enter client Number&quot;)
tc.open(&quot;clientTable&quot;)
if clientNum.isBlank() = false then
if tc.locate(&quot;client #&quot;,clientNum) then
; if tc.qlocate(clientNum) then ; use qlocate if client # is the primary key field, much faster.
f.open(&quot;cleint&quot;)
f.customer.movetorecord(tc)
; f.customer.setRange(custNum) ; use setrange to keep the user from moving off the record
else
MsgStop(&quot;Error&quot;,clientnum.string()+&quot; &quot;+&quot;Is Not a Valid Number&quot;)
endif
endif

tc.close()

Hope this helps
Perrin
 
I'm going to give this a try. I was thinking using a TCursor was going to be my solution. Just out of curiosity, how does one get the &quot; active.menuAction(MenuRecordLocateValue)&quot; to work?? I just can't seem to learn enough. I only ask so that if I would like a button to open a search box for whichever field the user is currently in, I think I would like to know that.

Thanks for all of your help! I appreciate it sooo much!
 
I'm not sure why you are having trouble with the active.menuAction(MenuRecordLocateValue) try replacing active with the name of the field object you want to search.

Perrin
 
kfenner,

Um, have you turned off your button's Tab Stop property? If not, that's why active.menuaction() isn't working. When you click a tab stoppable button, it receives focus and becomes active.

Alternatively, why not simply direct the menuAction to the Client field object, e.g.
Code:
client.menuAction( MenuRecordLocateAction )
?

Hope this helps...

-- Lance
 
Wow. Don't know what I would do without you guys! I tried Perrin's solution of replacing &quot;active&quot; with the field name, and that worked. I also went in and turned the tab stop off (didn't even know about that one - thanks Lance) and now I can search any active field! Thanks so much! I am learning amazing things with your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top