Macros and Programming
I'm trying to create a fairly complex database which includes one to many relationships. After some time learning about Cardbox it appears there's no easy way to do this, anyone have any idea? For example I have a record for a customer and a number of transactions relating to that customer.
Also, is it possible to use a macro to change the list of items in a drop-down list?
Hope someone can help.
Thanks, in advance.
The solution to this problem is built-in: relational searches (see manual):
Create two databases: one containing the customers including a unique customer ID and one containing the transactions, including the same unique customer ID.
The same could be done vice versa.
This example macro will only work correctly if you always use it to open the transactions database. If you open "transactions" manually, make a selection and then use this macro, no link will be set up.
on error resume next
if SelectionLevel = 0 then
Great, thanks very much, that should do the trick!
Any ideas about my other question; using a macro to change the list of items in a drop-down list?
For example, I wish to create a new transaction based on a customer already in the database. So I'd like to have a drop-down list with all my customers in it so I can select one.
As far as I know there's no way of changing the format file by means of a macro.
- Have both databases open (you can use the previously described macro for this).
The macro takes the customer ID of the current customer (remember you don't copy the entire customer data to the transaction, just the ID), switches to the Transactions database, and adds a new record with the correct ID already filled in.
You could have a "list view" in your Customer database, with just the customer's name and ID on a single line, to serve as your drop-down list. Put the button in the heading and you're done.
I reread my reply and realized that that last macro could be simpler using AddRecord instead of NewRecord:
|© 2010 Cardbox Software Limited|