I am trying to create a function that will allow me to use various command buttons without having to recreate the code every time.

To do this I have to pass the form name through a function

Function:

```
public Function NewRecord(controlForm, focusForm)
focusForm.SetFocus
DoCmd.GoToRecord , , acNewRecord
controlForm.SetFocus

```

controlForm - This is the main form akin to the Me function

focusForm - This is for not only the main form but when I create subforms I have to have the focus on the subform to have the command work.

To call the function I did the following:

```
public sub Command19_Click()
Dim controlForm
Dim focusForm

Set controlForm = Forms![frm_Sales_CustomerProfile]
Set focusForm = Forms![frm_Sales_CustomerProfile]

Call NewRecord(controlForm, focusForm)

End Sub

```

I get this error that States: Compile Error: Invalid Use Of Property.