Page 1 of 1

Showing more than one field at a time

PostPosted: Fri Aug 30, 2013 4:18 pm
by DELCO
Hello to all,

I don't know if i will be very clear, sorry :

Imagine you have a database with 3 fields ("name","phone","city") and you have 4 records.

Now, you have 4 buttons, and the caption of each button is a variable, the "name.field"

How can I have button 1, with "name" record 1 as caption, button 2, with "name" record 2 as caption, button 3, with "name" record 3 as caption, and button 4, with "name" record 4 as caption,
Is it possible ?

Regards,

Re: Showing more than one field at a time

PostPosted: Fri Aug 30, 2013 6:05 pm
by Gaev
DELCO:

I am not sure where the phone and city fields fit into your requirement.

You use ...

1) dbpFirst and dbpNext commands to navigate from the first to the 4th record

2) SetObjectCaption to set the caption of a Button

3) [MyDB.myTable.name] to get the value of the name Field (Assuming that your Database is called MyDB and the Table is called MyTable)

Assuming that you are familiar with other aspects of using Databases (like opening and closing databases and tables) ... your code might look something like this ...
Code: Select all
dbpFirst "MyDB" "MyTable"
SetObjectCaption "PushButton1" "[MyDB.MyTable.name]"
dbpNext "MyDB" "MyTable"
SetObjectCaption "PushButton2" "[MyDB.MyTable.name]"
dbpNext "MyDB" "MyTable"
SetObjectCaption "PushButton3" "[MyDB.myTable.name]"
dbpNext "MyDB" "MyTable"
SetObjectCaption "PushButton4" "[MyDB.MyTable.name]"

Re: Showing more than one field at a time

PostPosted: Sat Aug 31, 2013 2:11 am
by DELCO
Hello Gaev,
Thank you for your prompt answer.
I will try this today.
Thank you again, and have a good day !