I have a form that i have set as a subform
Here is my form
And here it is set as a subform
What my problem deals with is my duplicate record button on my subform (uses the new record icon)
The new record button has the following code (as a macro) on the event "on click"
I know that this is probably a weird way to do this, but since i could only have certain fields copied out of the record this was the only way i could come up with.
When i open my form by itself it works perfect. it creates a new record with all of the fields that i want and none of the ones that i do not.
When i run it as a subform though, it brings up the following error message.
and this is the macro Action Failed box that comes up after
I have changed it to make sure that everything is visible, i have changed it to visual basic, i have added code to make sure that the subform has focus, and i am now at a total loss
Does anyone know what could be wrong with this?
Thanks in advance
Here is my form
And here it is set as a subform
What my problem deals with is my duplicate record button on my subform (uses the new record icon)
The new record button has the following code (as a macro) on the event "on click"
Code:
'------------------------------------------------------------
' Macro11
'
'------------------------------------------------------------
Function Macro11()
On Error GoTo Macro11_Err
With CodeContextObject
DoCmd.SetProperty "RATE_OVERIDE", acPropertyEnabled, "1"
DoCmd.SetProperty "ZONE", acPropertyEnabled, "1"
DoCmd.SetProperty "TAX_RATE", acPropertyEnabled, "1"
DoCmd.SetProperty "NBHD_CODE", acPropertyEnabled, "1"
DoCmd.SetProperty "NBHD_GROUP", acPropertyEnabled, "1"
DoCmd.SetProperty "LINK_ID", acPropertyEnabled, "1"
DoCmd.RunCommand acCmdSaveRecord
DoCmd.SetProperty "RECID1", acPropertyEnabled, "0"
DoCmd.SetProperty "Combo35", acPropertyEnabled, "0"
DoCmd.SetProperty "Combo37", acPropertyEnabled, "0"
DoCmd.SetProperty "Combo39", acPropertyEnabled, "0"
DoCmd.SetProperty "ACRES", acPropertyEnabled, "0"
DoCmd.SetProperty "NUM_LOTS", acPropertyEnabled, "0"
On Error Resume Next
DoCmd.RunCommand acCmdSelectRecord
If (.MacroError = 0) Then
DoCmd.RunCommand acCmdCopy
End If
If (.MacroError = 0) Then
DoCmd.RunCommand acCmdRecordsGoToNew
End If
If (.MacroError = 0) Then
DoCmd.RunCommand acCmdSelectRecord
End If
If (.MacroError = 0) Then
DoCmd.RunCommand acCmdPaste
End If
If (.MacroError <> 0) Then
Beep
MsgBox .MacroError.Description, vbOKOnly, ""
End If
DoCmd.SetProperty "RECID1", acPropertyEnabled, "1"
DoCmd.SetProperty "Combo35", acPropertyEnabled, "1"
DoCmd.SetProperty "Combo37", acPropertyEnabled, "1"
DoCmd.SetProperty "Combo39", acPropertyEnabled, "1"
DoCmd.SetProperty "ACRES", acPropertyEnabled, "1"
DoCmd.SetProperty "NUM_LOTS", acPropertyEnabled, "1"
DoCmd.SetProperty "RATE_OVERIDE", acPropertyEnabled, "0"
DoCmd.SetProperty "ZONE", acPropertyEnabled, "0"
DoCmd.SetProperty "TAX_RATE", acPropertyEnabled, "0"
DoCmd.SetProperty "NBHD_CODE", acPropertyEnabled, "0"
DoCmd.SetProperty "NBHD_GROUP", acPropertyEnabled, "0"
DoCmd.SetProperty "LINK_ID", acPropertyEnabled, "0"
DoCmd.GoToControl "RECID1"
End With
Macro11_Exit:
Exit Function
Macro11_Err:
MsgBox Error$
Resume Macro11_Exit
End Function
I know that this is probably a weird way to do this, but since i could only have certain fields copied out of the record this was the only way i could come up with.
When i open my form by itself it works perfect. it creates a new record with all of the fields that i want and none of the ones that i do not.
When i run it as a subform though, it brings up the following error message.
and this is the macro Action Failed box that comes up after
I have changed it to make sure that everything is visible, i have changed it to visual basic, i have added code to make sure that the subform has focus, and i am now at a total loss
Does anyone know what could be wrong with this?
Thanks in advance