by Jack Wheeler
How convenient it would be to just push a button and advance the records in an embedded browse by as many records as are present in the browse!
This is a basic form with an embedded browse:

You will see there are two buttons just above the browse (named Browse1). The first button advances the browse by six records. There are 6 visible records on the browse.

Here is this code that advances the browse:
dim f as p dim t as p t=table.current() f = parentform.this f:browse1:name.activate() for i = 1 to 6 t.fetch_next() next i f:browse1.refresh()

I first thought about simply setting up a function that would this for me, however, once I started on the script it was so simple and so fast that I did not bother changing it at all!
Now since this was so easy, I thought, "Why not let the user find the member using the ui_get_text() function?" This too is a small and easy script that, once understood, can be used on every browse. In my example, the embedded browse shows only members that belong to the active company. This is done with a query operation.
Here is the message box:

And here is the browse with the members that start with a G:

Here is the code:
dim f as p
dim t as p
dim name as c
t=table.current()
f = parentform.this
f:browse1:name.activate()
name=ui_get_text("What Name?","The name begins with?")
t.fetch_find(name)
f:browse1.refresh()
Now if you want to find the member according to Social Security Number instead of by name, you could ask the user to choose the index and then find the value. All in one push of a button:
dim f as p
dim t as p
dim index as c
dim name as c
dim msg as c
dim msg1 as c
f=parentform.this
t=table.current()
index=ui_get_radio("Choose the Filter",1,"Social Security Number",\
"Last Name","first name","Address")
if index = "" then
end
end if
select
case index="Social Security Number"
index="SSN"
msg="Social Security Number"
msg1="What is the Number?"
case index="Last Name"
index="LastName"
msg="What is the Last Name"
msg1="Last Name begins with?"
case index="First Name"
index = "FName"
msg="First Name"
msg1="What does the First Name start with?"
end select
t.index_primary_put("index")
f:browse1:name.activate()
name=ui_get_text(msg,msg1)
t.fetch_find(name)
f:browse1.refresh()
I hope you find some value in this!
| Editor's note: For another take on synchronizing browses, see the article on Searching on a Child Record. You can reach Jack Wheeler at jwl1@jps.net |
2/28/00
Don't forget, we need your feedback to make this site better!