MS Access Forum / Forms / October 2005
Auto-copy data into a field
|
|
Thread rating:  |
Charles - 31 Oct 2005 09:16 GMT I've got a form where the user is entering orders. I'd like it to pull the price for an item from the master stock item table after the stock item is entered, but still allow the user to change that price if they'd like and store it in history (the underlying table for this form is the history table).
Any help would be greatly appreciated.
Ofer - 31 Oct 2005 09:42 GMT On the after update event of the stock item field you can write the code ' Incase the item number is number type use this Me.[Price Field Name] = Dlookup("[Price]","[master stock item table Name]","[Item Number] = " & Me.[Item Number Name In the form])
' Incase the item number is text type use this Me.[Price Field Name] = Dlookup("[Price]","[master stock item table Name]","[Item Number] = '" & Me.[Item Number Name In the form] & "'")
 Signature If I answered your question, please mark it as an answer. That way, it will stay saved for a longer time, so other can benifit from it.
Good luck
> I've got a form where the user is entering orders. I'd like it to pull the > price for an item from the master stock item table after the stock item is > entered, but still allow the user to change that price if they'd like and > store it in history (the underlying table for this form is the history table). > > Any help would be greatly appreciated. Ofer - 31 Oct 2005 09:52 GMT One more thing, add to the dlookup the NZ function to replace the Null with 0, incase the record is not found
Me.[Price Field Name] = NZ(Dlookup("[Price]","[master stock item table Name]","[Item Number] = " & Me.[Item Number Name In the form]),0)
 Signature If I answered your question, please mark it as an answer. That way, it will stay saved for a longer time, so other can benifit from it.
Good luck
> I've got a form where the user is entering orders. I'd like it to pull the > price for an item from the master stock item table after the stock item is > entered, but still allow the user to change that price if they'd like and > store it in history (the underlying table for this form is the history table). > > Any help would be greatly appreciated. Charles - 31 Oct 2005 20:50 GMT I tried this, but I get an error message that says Access can't find the Macro Me
> One more thing, add to the dlookup the NZ function to replace the Null with > 0, incase the record is not found [quoted text clipped - 8 lines] > > > > Any help would be greatly appreciated. Douglas J Steele - 31 Oct 2005 21:06 GMT Ofer meant for you to replace
Me.[Price Field Name]
with the actual name of the control on your form that you want the Price to go into, and
Me.[Item Number Name In the form]
with the actual name of the control on your form that contains the Item Number Name.
As well, he's assuming that Item Number is a numeric field.
 Signature Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!)
> I tried this, but I get an error message that says Access can't find the > Macro Me [quoted text clipped - 11 lines] > > > > > > Any help would be greatly appreciated. Charles - 31 Oct 2005 22:43 GMT I understood that, I tried the code sample he gave and substituted my own field and table names in all the appropriate places. The Me. function or macro seems to be the problem, Access doesn't recognize it, and unfortunately I'm not familiar with that one at all to be able to tell if there are any mis-prints. I did type it in exactly as it was posted.
And the fields in question are all numeric
> Ofer meant for you to replace > [quoted text clipped - 34 lines] > > > > > > > > Any help would be greatly appreciated. Ofer - 31 Oct 2005 22:49 GMT Can you post your code please?
 Signature If I answered your question, please mark it as an answer. That way, it will stay saved for a longer time, so other can benifit from it.
Good luck
> I understood that, I tried the code sample he gave and substituted my own > field and table names in all the appropriate places. The Me. function or [quoted text clipped - 42 lines] > > > > > > > > > > Any help would be greatly appreciated. Ofer - 31 Oct 2005 22:51 GMT One more thing, i got this error once in a certain form, and it require that I'll write the code as Me![FieldName]
 Signature If I answered your question, please mark it as an answer. That way, it will stay saved for a longer time, so other can benifit from it.
Good luck
> I understood that, I tried the code sample he gave and substituted my own > field and table names in all the appropriate places. The Me. function or [quoted text clipped - 42 lines] > > > > > > > > > > Any help would be greatly appreciated. Charles - 31 Oct 2005 23:30 GMT Me.[Cost] = DLookUp("[Cost]","[Stock Items]","[Stock #] = '" & Me.[Stock #] & "'")
Please note - Several of the fields have identical names in different tables. IE the History Detail table and the Stock Items table both have fields named [Cost] and [Stock #]
I tried this same code using the exclamation points after Me instead of periods, no luck.
> One more thing, i got this error once in a certain form, and it require that > I'll write the code as [quoted text clipped - 46 lines] > > > > > > > > > > > > Any help would be greatly appreciated. Ofer - 31 Oct 2005 23:40 GMT When I said to put the code in the after update event of the form, I ment in the code section and not directly in the line of the property.
When you in the propery, click on the button with the three dots, and select code, in the code enter the this line. The reason that I'm asking that is, if you put something directly in the line, it will look for a macro with this name, and mybe this is why it prompt you with this message.
 Signature If I answered your question, please mark it as an answer. That way, it will stay saved for a longer time, so other can benifit from it.
Good luck
> Me.[Cost] = DLookUp("[Cost]","[Stock Items]","[Stock #] = '" & Me.[Stock #] & > "'") [quoted text clipped - 56 lines] > > > > > > > > > > > > > > Any help would be greatly appreciated. Charles - 01 Nov 2005 00:01 GMT That did the trick, thank you so much for your help!
> When I said to put the code in the after update event of the form, I ment in > the code section and not directly in the line of the property. [quoted text clipped - 65 lines] > > > > > > > > > > > > > > > > Any help would be greatly appreciated.
|
|
|