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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to append form with two tables

Status
Not open for further replies.

foamlady

Technical User
Mar 16, 2011
21
US
I have a basic invoicing application.

Customer table... index on record number
Item purchased table . linked with record number to customer table.
Could have multiple records of item purchased to one customer
Use combo box from description table to help in finding item number.
Need code to append both tables and bring up blank fields for both tables and combo box

Thank you
from a very tired Grandma
 
OK, so you have a fairly ordinary m:m table setup:

Customer <-->> Purchases <<--> Items

Got that so far. Here's where you lose me:

Need code to append both tables and bring up blank fields for both tables and combo box

Um, which both? You have three tables in play. Append what? How does a combo box come into it and what do blank fields have to do with anything?
 
Actually Dan I think it is
Customer <<--> Items (purchased)

But, like you, I have no idea from there as to what is needed and why.

Perhaps if we get more clarity we can offer better assistance.

foamlady - Good Luck,
JRB-Bldr


 
Sorry guys I will explain further but THANKS, I wasn't sure if anyone would even care.

My entry screen form has on the top part customer information (table 1) to include fields of date, recordnumber computer generated, name, credit card information.
The next part of the form (table 2) has the purchase information which includes fields of recordnumber, item number, item qty -- first line; repeat the same for second line, record number, item number, item qty -- repeat the same for the next 7 lines. In each line there is a combo box that contains another table that lists all item numbers and descriptions so when clicked on it enters that item number in the correct column. The combo box table does not need to be appended but does need to go back to "blank", now it seems to remember the last entry.
I have several command buttons
print this provides an invoice for the customer and a copy for myself -- my code is with a do program.
The command button to save the form to both the customer table and the purchase information table and advance to a new "empty" screen/form is the one I am having trouble with. That's the code I need.
Does not work
Append blank
Form1.Refresh
Hope this helps clear up questions.
 
To make the item combo appear blank, you'll need to explicitly add a blank item to it (I'm assuming that its Style property is set to 2, which is correct in this context).

You can add a blank item by using a cursor to populate the combo. The cursor will contain exactly the same records as your items table, but with the additional blank record at the top.

Alternatively, you can set the combo's RowSourceType to 0, then loop through the table, adding each item via the AddItem method. Add a blank item as the first one, then add each record from the table.

Either way, when you are ready to enter a new order, you need to set the combo's ListIndex to 1 (which is why the blank item has to be at the top).

As for clearing all the other fields for a new order, doing an APPEND BLANK and then refreshing the form should do it. If that's not working, check that you are appending to the correct table. You can't make any assumptions about which work area will be selected; you need to SELECT it explicitly.

Also, I'm assuming that the ControlSource in all the controls is correctly set. If they are not, that would explain why it's not working.

Hope this helps.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top