Hello everyone,
First of all, thanks ahead of time to everyone on this board who takes the time to respond to questions from people like me! I couldn't function without you!
I have a fairly run-of-the-mill database which keeps track of my manufacturing work orders, packing slips and routers (work instructions for shop floor workers). Due to my busy schedule, I can only update and modify the database to work better during my free time, when I actually feel like working on it. As such, I am essentially a complete beginner when it comes to Microsoft Access (2010 x64).
What I am trying to accomplish seems so incredibly simple, but I swear I am going to tear all of my hair out if I don't figure it out soon. Right now I manually enter all of the data into a work order, either from a customer purchase order or a verbal order over the phone or by email. The work order is a main form containing customer information with a subform containing one record for each product on the purchase order. These records contain the part number, description, quantity, price, etc. Once I have the work order created, I need to create a router for each product on the work order. This will contain both the customer data AND the product data, and is used as a set of instructions for the workers on the shop floor to create the product. On to the first problem...
I want to simply copy all of the customer data and product data from the form and subform, and create a router for each product containing the appropriate information from each record. I have been successful in copying all of the customer data and transferring it to a new record on the routers form, but the subform data is proving difficult. Each work order has a "Work Order Number" primary key which is bound to an autonumber primary key on the subform. So, each record (many) in the subform is bound to a single work order (one). I have been trying to copy the value of the "Work Order Number" to be able to search the subform table and copy the appropriate data using a loop, but I seriously cannot get the VBA code to copy the value of the current records "Work Order Number" field. I even created a button with a few of the most basic lines of code to try to do this and cannot get it to work.
Code:
Private Sub Command199_Click()
dim msg as integer
msg = workordernum
MsgBox msg
End Sub
This always returns "0" no matter what record I'm on. I have tried everything I can think of to get it to read this value and 99% of my attempts have resulted in errors so far. I have tried using the currentdb, currentrecord, me., and various other methods, but nothing seems to work. Oddly enough, I can do the following without any problem,
Code:
Private Sub Command199_Click()
dim msg as string
msg = customer
MsgBox msg
End Sub
This displays the customer name from the current record with no problem at all. Does it have something to do with the fact that the "Work Order Number" is the primary key? Any help here would be appreciated. I'm feeling completely defeated right now, trying to do something so easy.
Thanks![/novel]