Questions about duplicating records (1 Viewer)

dkmoreland

Registered User.
Local time
Yesterday, 19:46
Joined
Dec 6, 2017
Messages
129
I am trying to duplicate the record on a form and at the same time, add values to the new duplicate record that are not displayed on the form but are present in the table.

For example, the form fields are id, job number, order qty, mfgdate and po number. I'm duplicating everything except the po number, which will be edited in the new record.

The original record also has a few other fields in the table that I want to populate in the new record but they are not displayed on the form. The duplication works for all the fields that are displayed on the form but the value for the ones that are not is coming back as null in the debugger.

Here is the code I am using - the values that are coming back as null are highlighted in red. What am I doing wrong?

Code:
Private Sub CmdAddPO_Click()

On Error GoTo Err_CmdAddPO_Click

Dim pjob As Variant
Dim pmfgdate As Variant
Dim plabel As Variant
[COLOR="red"]Dim prefid As Variant[/COLOR]
[COLOR="Red"]Dim punwind As Variant[/COLOR]
[COLOR="red"]Dim pcoatype As Variant[/COLOR]


pjob = [Job #].Value
pmfgdate = [COA Manufacture Date(s)].Value
plabel = [GCAS / Item / or HCI #].Value
[COLOR="red"]prefid = ReferrenceID.Value
punwind = [Unwind Direction].Value
pcoatype = COAType.Value[/COLOR]

RunCommand acCmdRecordsGoToNew

[Job #].Value = pjob
[COA Manufacture Date(s)].Value = pmfgdate
[GCAS / Item / or HCI #].Value = plabel
[COLOR="red"]ReferrenceID.Value = prefid
[Unwind Direction].Value = punwind
COAType.Value = pcoatype[/COLOR]

   
Exit_CmdAddPO_Click:
    Exit Sub

Err_CmdAddPO_Click:
    MsgBox Err.Description
    Resume Exit_CmdAddPO_Click
    
End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:46
Joined
Aug 30, 2003
Messages
36,133
The simplest solution may be to add them to the form but hide them.

Edit: This may also work:

prefid = Me!ReferrenceID
 

dkmoreland

Registered User.
Local time
Yesterday, 19:46
Joined
Dec 6, 2017
Messages
129
I did end up adding them to the form but hiding them. Thanks for the suggestion!
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:46
Joined
Aug 30, 2003
Messages
36,133
Happy to help!
 

Users who are viewing this thread

Top Bottom