Creating new record and copying value

D

Daniel Lees

Hi

I have a table("Sales Details") that has a "job no" and i want to create a
new record in another table("New Part Notification") and copy the "job no"
from "Sales Details" into a field called "ref" in "New Part ...".

Is there a simple way to do this? I have asked a similar question before and
some1 gave me some VBA code but i couldn't get it to work.

Cheers

Danny
 
A

Arvin Meyer [MVP]

Daniel Lees said:
Hi

I have a table("Sales Details") that has a "job no" and i want to create a
new record in another table("New Part Notification") and copy the "job no"
from "Sales Details" into a field called "ref" in "New Part ...".

Is there a simple way to do this? I have asked a similar question before and
some1 gave me some VBA code but i couldn't get it to work.


Hopefully, you'll get this to work. <g>

If you use OpenForm method, notice that the last argument is called
OpenArgs. You can use this argument to pass a string to the form you are
opening. For example:

Sub cmdMyButton_Click()

DoCmd.OpenForm "New Part Notification", , , , , , Me.[job no]

End Sub

Once you have the form opened, you can refer to OpenArgs as a property of
the form.

Sub Form_Open(Cancel As Integer)

Me.[ref] = Me.OpenArgs

End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Top