This topic is locked

Copying fields from one table to another?

2/26/2009 8:25:59 PM
PHPRunner General questions
greggk author

Hello,

I'm new to this. I downloaded the trial version, and so far I think it's great.

I have what I hope is a very simple question and a simple solution <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=11041&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />

Let's say I have two tables, "Products" and "Vendors"

The vendor table would have for example fields like "vendorID,VendorName,VendorAddress" etc etc.

The product table would have "productID,vendorID,VendorName,ProductName" etc etc

So, in the product add and edit pages I have added a dropdown menu for the VendorName and I'm pulling the information from the Vendor Table field "VendorName" By adding the VendorName to the Product that links the vendor to that particular product, but how do I automatically assign the appropriate Vendor ID without having to type it in? So basically what I want to do is, when adding a new product, I select the Vendor from a dropdown Menu and I want it to automatically add the VendorID too. Hopefully this makes sense. Thanks in advance for any suggestions.

R
rgfischerjr 2/26/2009

By adding the VendorName to the Product that links the vendor to that particular product, but how do I automatically assign the appropriate Vendor ID without having to type it in? So basically what I want to do is, when adding a new product, I select the Vendor from a dropdown Menu and I want it to automatically add the VendorID too. Hopefully this makes sense. Thanks in advance for any suggestions.


If you include VendorID in the fields and (in Visual Editor) set the properties to use the Lookup Wizard you can display the Vendor to the user and select the VendorID behind the scenes. See Lookup Wizard in the help file.

greggk author 2/27/2009

If you include VendorID in the fields and (in Visual Editor) set the properties to use the Lookup Wizard you can display the Vendor to the user and select the VendorID behind the scenes. See Lookup Wizard in the help file.


This was actually an easy fix, however it does pick the VendorName from the VendorID but now when the new user is added, it leaves both the VendorID and the VendorName blank. Any thoughts on that?

Sergey Kornilov admin 2/27/2009

Hard to tell hat might be wrong without seeing your files.
There is one thing I can suggest. According to good database design rules you don't need both VerndorID and VendorName in Products table. Having a single VendorID field is more than enough. Setup lookup wizard for this field, use VendorID as a link field and VendorName as a display field. This is it.

greggk author 2/27/2009

Hard to tell hat might be wrong without seeing your files.

There is one thing I can suggest. According to good database design rules you don't need both VerndorID and VendorName in Products table. Having a single VendorID field is more than enough. Setup lookup wizard for this field, use VendorID as a link field and VendorName as a display field. This is it.


I did what you suggested, and removed VendorName from Products, and only use VendorID. So, the products Table looks something like this: ProductID/ProductName/VendorID/ and the rest of the information.

The Vendor table looks something like this: VendorID/VendorName/Address/Phone/Contact etc etc.

From the Datasource tables I have added a link from VendorTable VendorID to ProductTable VendorID

From the Visual Editor I have created a drop down menu using the look up wizard that uses VendorID as the LinkField and Vendor Name as the Display. Testing it by adding a product, I get the pulldown with the vendors, and I select one of them and add a product, and when I display it, for VendorID is shows up as 0. Now if I edit the same product that I just added, and reselect the same vendor, then it shows up as the correct vendor when I list it.

Sergey Kornilov admin 2/27/2009

Do I understand it right it doesn't work on Add though works on Edit?
If yes, you can post your application to 'Demo Account' (last screen in PHPRunner) and open a ticket at http://support.xlinesoft.com sending your application URL.

greggk author 2/27/2009

Do I understand it right it doesn't work on Add though works on Edit?

If yes, you can post your application to 'Demo Account' (last screen in PHPRunner) and open a ticket at http://support.xlinesoft.com sending your application URL.



Yes, that's exactly right, when you do add, it puts a 0 in the field, however when you do edit, and choose the vendor, it does it inserts it correctly. I will post the app as you requested.

Sergey Kornilov admin 2/28/2009

Greggk,
answered to your personal email.
In short: it appears you use unnecessary master-details relationships and advanced security that involve Products table. With this setup VendorID value is overwritten with VendorID value from login table which happens to be 0 if you logon as admin.
To fix this simply remove master-details relationship and turn off advanced security for Products table.