M
MarkB
I am trying to write code to make a copy of the data on a form, create a new
record, paste the data and add "-copy" to the CustPartNumber field.
I am able to get this to work but,
I then want to look at the autocounter for that new record "[PartID]" and
the reopen a form using that PartID value.
Here is a portion of the code that almost works, but i can only seem to get
the original PartID not the new one I just created??
DoCmd.Echo False, 'hides the opening of the products table
DoCmd.OpenTable "Products", A_NORMAL, A_EDIT 'opens the products table
DoCmd.FindRecord Me![PartID] 'finds the partid in the table that matches
partid on the open form string DocName
DoCmd.Close acForm, DocName ' now that I have the record i want close the form
DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD_V2, , A_MENU_VER20
'selects the whole record
DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_COPY, , A_MENU_VER20 'copies it
DoCmd.GoToRecord , , A_NEWREC 'goes to new record
DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, 6, , A_MENU_VER20 'Paste Append 'paste
DoCmd.GoToControl "CustPartNumber" 'goes to custpartnumber
SendKeys "{F2}" & "-COPY" & "~", True 'adds -copy to custpartnumber and
sends the enterkey
DoCmd.SetWarnings False 'prevents the "you have coppied lagre amountof
data to clipboard error
DoCmd.Save
stPartID = ?????????? ' this is the line i'm having trouble with i need the
PartID of the current record in the Products table???
'DoCmd.Close 'closes products table
DoCmd.Echo True 'turns echo back on so you can see your database
MsgBox "This record has been coppied !", 48, "ORS ALERT"
Debug.Print stPartID
frmReopenPartID = "[PartID]=" & stPartID
Debug.Print frmReopenPartID
Debug.Print stCustPartNumber
'DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm DocName, acNormal, , frmReopenPartID, acFormEdit,
acWindowNormal ' i plan to reopen the form to the new partid ,
CustPartNumber-COPY
record, paste the data and add "-copy" to the CustPartNumber field.
I am able to get this to work but,
I then want to look at the autocounter for that new record "[PartID]" and
the reopen a form using that PartID value.
Here is a portion of the code that almost works, but i can only seem to get
the original PartID not the new one I just created??
DoCmd.Echo False, 'hides the opening of the products table
DoCmd.OpenTable "Products", A_NORMAL, A_EDIT 'opens the products table
DoCmd.FindRecord Me![PartID] 'finds the partid in the table that matches
partid on the open form string DocName
DoCmd.Close acForm, DocName ' now that I have the record i want close the form
DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD_V2, , A_MENU_VER20
'selects the whole record
DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_COPY, , A_MENU_VER20 'copies it
DoCmd.GoToRecord , , A_NEWREC 'goes to new record
DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, 6, , A_MENU_VER20 'Paste Append 'paste
DoCmd.GoToControl "CustPartNumber" 'goes to custpartnumber
SendKeys "{F2}" & "-COPY" & "~", True 'adds -copy to custpartnumber and
sends the enterkey
DoCmd.SetWarnings False 'prevents the "you have coppied lagre amountof
data to clipboard error
DoCmd.Save
stPartID = ?????????? ' this is the line i'm having trouble with i need the
PartID of the current record in the Products table???
'DoCmd.Close 'closes products table
DoCmd.Echo True 'turns echo back on so you can see your database
MsgBox "This record has been coppied !", 48, "ORS ALERT"
Debug.Print stPartID
frmReopenPartID = "[PartID]=" & stPartID
Debug.Print frmReopenPartID
Debug.Print stCustPartNumber
'DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm DocName, acNormal, , frmReopenPartID, acFormEdit,
acWindowNormal ' i plan to reopen the form to the new partid ,
CustPartNumber-COPY