PDA

View Full Version : add an object that can be used throughout app


tripro
11-07-2010, 08:07 PM
Hi Thomas,

As you suggested, adding this to the wishlist :)

A software object that can be setup as a setting (ie, password, email address, code, special text, etc - only one record) that can be used throughout the app, for example in a calculated field, etc.

Thanks!

Mark

RichHamilton
11-08-2010, 09:13 AM
I've used a table/object in other database systems for this.. a 1-record table that could hold client name, address, whatever, could be accessed in reports or other objects to display these things. Very useful.

aussieokie
11-08-2010, 05:33 PM
I've used a table/object in other database systems for this.. a 1-record table that could hold client name, address, whatever, could be accessed in reports or other objects to display these things. Very useful.

Mark and Rich,
You can set up a single record object that can be used throughout a TSB project.
In particular you can use it for adding as Rich suggests an address, and or company
name and so on. You can include calculated fields in the object and include them
in other objects using relationships. However, you can't use a calculated field or any
other field from one object and use it in conjunction with a field from another object.

Calculations can only occur between fields in the same object. This is something
I'd love to see changed :D at some point.

The only place that calculations between fields in different objects can occur is in reports.

If you want to use an object with a single record in your TSB projects have a look
at the following post and the link Robbie provides.

This works for any single record object.

http://profittigersystems.com/vbforum/showthread.php?t=1272 (http://profittigersystems.com/vbforum/showthread.php?t=1272)

or go straight to the original post:

http://profittigersystems.com/vbforum/showpost.php?p=7777&postcount=8 (http://profittigersystems.com/vbforum/showpost.php?p=7777&postcount=8)

Cheers
Jim

RichHamilton
11-08-2010, 10:45 PM
Well, Jim,

By Golly, you're right.

I'd even read that before and not realized what it meant to me.

I DO agree about the calculations. It would be a good place to enter a tax rate or some such thing that would be applied to a value in another object.

tripro
11-08-2010, 10:46 PM
Mark and Rich,
You can set up a single record object that can be used throughout a TSB project.
In particular you can use it for adding as Rich suggests an address, and or company
name and so on. You can include calculated fields in the object and include them
in other objects using relationships. However, you can't use a calculated field or any
other field from one object and use it in conjunction with a field from another object.

Calculations can only occur between fields in the same object. This is something
I'd love to see changed :D at some point.

The only place that calculations between fields in different objects can occur is in reports.

If you want to use an object with a single record in your TSB projects have a look
at the following post and the link Robbie provides.

This works for any single record object.

http://profittigersystems.com/vbforum/showthread.php?t=1272 (http://profittigersystems.com/vbforum/showthread.php?t=1272)

or go straight to the original post:

http://profittigersystems.com/vbforum/showpost.php?p=7777&postcount=8 (http://profittigersystems.com/vbforum/showpost.php?p=7777&postcount=8)

Cheers
Jim

Hi Jim,

Thanks much for the suggestions!

I used the method that Robbie outlined to make the browser screens and they worked very well.

However with a one record field shareable with another software object, even with a relationship connection, couldn't make it work.

Could not stop a user from adding a new record since the 'saving' rule will override and either I have to remove it or use it only to have a true rule that checks the data properly. I normally add the text 'you cannot delete this record' or something similar to the delete field rule comparison, and it works well. Just can't do that to the save since it won't save any data :) Maybe there's a way around this, perhaps a 'new' rule?

Also, even though other relationships work and seem to share the software object editors in a calculated field, couldn't get this one to work regardless how I setup the relationship.

Did I misunderstand your suggestion? Thanks again for your help!

Mark

aussieokie
11-09-2010, 10:17 AM
Mark,
To enforce the one record rule all you need to
do is add a field that's not required. In an example
database I'm trying to finish I use CompanyID.

Note, this was not the default field, just the one that
had the rules set. I used Company Name as the
default.

CompanyID is the field that has the save and delete
rules. Run your database and navigate to the single
record view. In my case I added a Company ID and
saved the record. I then went back into the records
display view and then right clicked to get to the customize
layout. I deleted the CompanyID from the layout, closed
the display and then made the changes to the menu to
ensure that the grid view disappeared.

By entering data into the CompanyID field I'm meeting
the rules of the database, i.e. required on save and
delete. By making this field invisible you can't enter
any new data because you can't fill in the CompanyID.
This triggers the rules and thus stops you from being able
to add a new record.

The whole trick to this is to have a field that contains
junk data that is not the default and becomes "invisible"
and another field containing pertinent data that is the
default. If you don't have this default field then you can't
form the relationships.

In my example I use this to store my own companies
information: Company name, Street Address, City, etc.
I have a calculation to combine all the address info
and I can now pull this into any other object that
relationships are set up. It's really handy for reports
and mail merge etc.

If you have any more questions don't hesitate to ask.

Cheers
Jim

tripro
11-09-2010, 12:19 PM
Mark,
To enforce the one record rule all you need to
do is add a field that's not required. In an example
database I'm trying to finish I use CompanyID.

Note, this was not the default field, just the one that
had the rules set. I used Company Name as the
default.

CompanyID is the field that has the save and delete
rules. Run your database and navigate to the single
record view. In my case I added a Company ID and
saved the record. I then went back into the records
display view and then right clicked to get to the customize
layout. I deleted the CompanyID from the layout, closed
the display and then made the changes to the menu to
ensure that the grid view disappeared.

By entering data into the CompanyID field I'm meeting
the rules of the database, i.e. required on save and
delete. By making this field invisible you can't enter
any new data because you can't fill in the CompanyID.
This triggers the rules and thus stops you from being able
to add a new record.

The whole trick to this is to have a field that contains
junk data that is not the default and becomes "invisible"
and another field containing pertinent data that is the
default. If you don't have this default field then you can't
form the relationships.

In my example I use this to store my own companies
information: Company name, Street Address, City, etc.
I have a calculation to combine all the address info
and I can now pull this into any other object that
relationships are set up. It's really handy for reports
and mail merge etc.

If you have any more questions don't hesitate to ask.

Cheers
Jim


Thanks very much Jim! Believe I'm catching on now :)
Have the fields and layout working ok, just can't get
the relationship set properly since it still doesn't show up
in any calculation field (after setting the relationship).

What I'm using here is an email address the user enters
that I'd like to have show in a software object.

I setup a email settings software object with two editors
(fields), one is emailid and is the default and is required,
and one is the actual emailaddress which has a save rule.
I added a record to the emailid field and saved, removed
it from the customization screen, made the change in the
model window to show detail view and this part works
just as you outlined. Can't add a new record and can't
delete the existing record. Perfect.

Setup a relationship between another software object
and this one. Tried it with one to one, one to many and
flipped this email object as the primary as well as child
and all ways doesn't show the object when making a
calculated field. When I customize the screen, the other
database object does show up as a drop down object,
but the fields don't show when creating a calculated
field.

What I'm trying to do is to show this email address in
another software object as part of a calculated field.
The user adds an email address in single record setting
and with the relationship setup, was hoping to have
it show in the other software object.

I know I must be missing something here :) and really
appreciate your help and detailed description Jim!

Mark

aussieokie
11-09-2010, 04:28 PM
Mark,
If you made emailID the default
that's the problem. The "Junk"
editor should only have the rules.
It's not the default and is the one
you remove from your layout.

The editor that has the actual data
is the default and has to show in your
layout. That's the only way it will work. :D
It will show as a drop down list with only
a single entry. It has to be this way so that
you can associate it with the related
records.

This can't be used in a calculated field using
fields from another object. Unfortunately
we can't do anything like SQL joins between
objects except in reports.

(hint hint Thomas LMAO)

Calculations that appear in layouts can
only happen between editors in the same
object. The results of the calculation can
be used in conjunction with any object
that it has a relationship with.

Glad to hear you're making in-roads.

Cheers
Jim

P.S. I'll try to get something up on my
site about this in the next few days.

tripro
11-09-2010, 05:31 PM
This can't be used in a calculated field using
fields from another object. Unfortunately
we can't do anything like SQL joins between
objects except in reports.

(hint hint Thomas LMAO)

Calculations that appear in layouts can
only happen between editors in the same
object. The results of the calculation can
be used in conjunction with any object
that it has a relationship with.


Aha! That's why it wasn't working :) I was
under the impression it would when you mentioned
you were using your company contact information
throughout the app, but now I understand, that
wasn't in a calculated field. You just used a calculated
field in the -same- software object and used the
result in any software object layout it had a relationship
with. Ok, now it's making sense! :)

Ok, so what I'm trying to do will definitely not work
until a join between objects is available. Got it.

I can see how it's working for a situation like yours
were you add the result of a calculation in any layout
with a relationship. Makes sense.

Thanks again for your help Jim!

Mark

aussieokie
11-09-2010, 08:09 PM
Pleasure Mark,
glad to hear you got it all worked out :D

Cheers Jim