views:

60

answers:

2

I have a table that stores invoices and a form based off of that table that looks like an invoice so that you can search previous invoices. Currently I am creating the invoices in excel and then exporting the data as a new record into the Invoice table. I was wondering if there was a way I could create the invoices from my Invoice form. I have a table of all of the products and prices we carry that would used for the invoice. Is there a way to put a search button on the invoice form that would search for a record or "product" in the product table and insert it into the fields of a new invoice? I have looked a some code to connect to the products table and insert it into fields in the invoice form, but how do I search as well? Any thought or ideas? Any help would be much appreciated!!

A: 

Not sure this is the right design. Do you only invoice one product at a time?

Also, it doesn't sound as if you are thinking in terms of primary keys.

Nor does it sound as if you thinking "relationally".

Let me clarify. In most invoicing systems, there is usually an Invoices table, then an InvoiceItems table. The relationship between the invoice items and the invoice would be one invoice to (potentially but not necessarily) many items.

Then you have your Products table. The relationship between the Products and InvoiceItems is one product to many InvoiceItems. Ie, you can sell a given product to many different customers.

So we have:

Invoices -->  InvoiceItems
Products -->  InvoiceItems

Now you need to implement this in your forms.

Matching your tables and their relationships, you create an InvoiceForm and you create an InvoiceItemsSubForm. The InvoiceItemsSubForm, to hold many items, is a continuous form.

In the InvoiceItemsSubForm, you will have a field that takes the Primary Key of the Product (along with other fields such as date, number of products purchased, etc).

To search for your products, you can have a combo box that has the ProductId and ProductName fields. This combo box serves two purposes: it allows you to search for your products, and it allows you to input the product you want in your InvoiceItem record.

If I have misunderstood your question, my apologies. If I haven't misunderstood your question, you have a lot to learn...

awrigley
No, you have not misunderstood my question. I think I have not explained myself clearly. I will explain the whole situation for you. First, I have a master Products table which contains all of the different brands of products we carry and the price we buy the product for. Off of the products table I have different price levels based on the price we buy the product at and the quantity the customer buys. We also have some individual customer queries b/c we give some a break on certain products. So linking a price to a products is pretty hard for invoicing b/c one product could have many prices.
Lars
as well as customers having many different products. This describes the product pricing part of the database. Next I have an invoicing side. Originally I set up the invoicing like this; I imported two tables into an excel file, customers and products. Then I set up the format of the invoice. I used combo-boxes to get the info from the imported tables into the invoice. After the invoice was complete I created a macro to write the info from the invoice to a table that stored a copy of the invoice. Then I created a form that loaded the stored invoices so that I could look up an invoice or make
Lars
changes. Then I got to thinking. Is there a way I can use the invoice form to search for products from the products table and insert the data into a line on the invoice. This way I wouldn't have to go through excel. The way I had to do in in excel is have a combo-box for each line on the invoice and I'm sure I would have to do that here too. I would prefer not using a combo box b/c we have almost 2000 products and trying to find one product in a combo box with that many products is a pain in the ass. Does this make any more sense now?
Lars
maybe I am still going about this the wrong way?
Lars
Lars, you are asking too many questions all at once. Break the problem down. Right now you've lost me, it will take me an hour just to figure out what your app is doing. People pay me for that. I'm always willing to help on specific issues, but not to try and figure out what is wrong with your whole app.
awrigley
All of what I just said is done and working. All I want is a way to search for a product and insert it in to my invoice form
Lars
+2  A: 

Handling this through VBA and control events is typically the best choice:

  1. Use an unbound text box in your form as your search input field. This will allow the user to input some text into a box and hit enter, or click some related "GO" button if you choose to perform some sort of search.
  2. Set the `OnChange` property of this text box control to the name of the macro or method you designed to handle this event (or click event property if you've instead set up a button to a) check the textbox value; and b) handle it; typically allowing for both the user pressing enter or clicking the button to perform this action). You may also simply call an `inputbox` from some button click event to pop up a prompt to allow the user to enter the product value to search for.
  3. Within your handling script, use DLookup() to use that user-supplied value against your products table to get some meaningful product value back which you can then place anywhere on your form.

Also, although I'm not familiar with your particular setup, it seems as though you should ditch your excel file and go with a direct user interfacing MS Access input form. You may find it always easier to deal with user input directly rather than indirectly through oustide files. That way, you have better control over user input validation and user feedback vs fearing whatever the Excel client feels like putting in those spreadsheets.

bob-the-destroyer
"boundless text field"? Do you mean "unbound textbox"?
David-W-Fenton
Yes, just being lazy with naming conventions.
bob-the-destroyer
Well, it's confusing. Fix it or risk a downvote.
David-W-Fenton
Wow, you edited that into a really excellent answer -- +1.
David-W-Fenton