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!

carry over information in fields to second form

Status
Not open for further replies.

kfenner

Technical User
Apr 6, 2003
52
US
I am relatively new at this, so please bear with me if I don't ask this correctly. I have created a databse which consists of two table. Both tables have two fields which are common: "clientno" and "matter no"........first form has a button which calls up a second form to enter contact information. Second form operates as a dialogue box. Both forms show the common two fields......I need to know how to get the information input into the first form in these fields, to appear in the second form when it is called up automatically........in other words, when I am in a record that has the "clientno" and "matterno" filled out, and I call up the add contact info form, I want the data in the fields to carry over so it doesn't have to be entered manually again. Can someone help me?

I am also wanting the second form, to open up in edit mode when it is called up. Since this second form is a dialogue box, I don't know if I can do it. Any help would be greatly appreciated!
 
kfenner,

Perhaps the easiest way is to use something along these lines:

Code:
var
   fmDialog  Form
endVar

   fmDialog.open( "2NDFORM" )
   fmDialog.action( dataBeginEdit )
   fmDialog.action( dataInsertRecord )
   fmDialog.ClientNo.Value = ClientNo.Value
   fmDialog.MatterNo.Value = MatterNo.Value
   fmDialog.wait()
   if fmDialog.locked then
      fmDialog.action( dataPostRecord )
   endIf
   try
      fmDialog.close()
   onFail
      ; do nothing; it's already closed
   endTry

Now, this is a very basic approach, one with little to no error checking. (It's also off the top of my head, so you may need to modify things a bit in case I mistyped something or your two objects have different names.)

It also assumes that you don't already have a record in your second table for the CLientNo/MatterNo combination. If you do, you can replace the dataInsertRecord line with one that locates the combination of values instead. See locate() for UIObject's in the ObjectPAL Reference Help file for more information.

Hope this helps...

-- Lance
 
Thank you for the help. I am assuming this code goes under the event for "pushbutton"? I told you, I'm new, so sorry if that is a stupid question.
 
kfenner,

Yes, it does.

Also, do yourself a huge favor, go to Developer Preferences, and then activate the Show Developer Menus on the General tab. This will places a Program menu in the main menu every time you open a form in Design mode. It's got a couple of menu commands you'll want to use pretty heavily as you get the hang of things:

-- Compile With Debug adds a bit of extra information to the form, information that's more specific about ObjectPAL Error messages.

-- Compiler Warnings helps you keep from making some basic mistakes, such as not declaring variables and so on.

It's basically a little extra information that's expecially helpful while you're learning the ropes.

Hope this helps...

-- Lance

2.
 
Thank you so much for the assistance. This works fine, but now I have encountered another problem. You can tell I am new to this, and unfortunately there is no support available to me.

The "contact" form now comes up with all the proper carryover information and that is wonderful. But, in order to call up this form from the "client" form, as I have it set up, the tables were linked together through the "clienNo" field, which of course has to be a key field in order to link them. Problem arrises in that there may be multiple contacts for any given client, therefore, you get a key violation because multiple contact records cannot have the same clientNo. The same issue happens if using the "matterNo" field. There are no other common fields I can use to link these tables. If I remove the keys, and thus the link, then I can't call up the "contact" table with a button on the "client" form. Any ideas, and remember....I'm a novice! LOL
 
kfenner,

You need to add a field to the second table's key field, e.g. kay it on ClientNo and MatterNo. This lets you have multiple matches for the same Client number, though you'll only be able to have one detail record for the same client/matter number combination.

If you need more than one record matching each combination of client/matter numbers, then create a three field key.

You might take a few moments to review which provides a pretty good overview of the basics. That sitre also contains some other useful materials as well.

Hope this helps...

-- Lance
 
Thanks. I'll try these suggestions. I have read alot of material, but still getting somewhat familiar with some of the concepts. I really appreciate your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top