Share via

Run-Time Error 3077

Anonymous
2011-11-05T11:44:45+00:00

I have a main form and a subfom that default view is datasheet. When I right click the subform and select "New Record" I get the following error"

'Run-Time Error 3077:

Syntax error (missing operator) in expression.'

Not sure if it matters but I have the following code in the on current of the subform to syn the records with the main form:

Private Sub Form_Current()

 Dim rst As DAO.Recordset

    Set rst = Me.Parent.RecordsetClone

    rst.FindFirst "MtceID = " & Me!MtceID

    If Not rst.NoMatch Then

        Me.Parent.Bookmark = rst.Bookmark

    End If

    Set rst = Nothing

    DoCmd.RunCommand acCmdSelectRecord

End Sub

At first I thought it was the DoCmd line and remarked it out, but I still got the error.

The right click Delete Record works fine.

Any ideas how to .prevent this error.

James

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2011-11-05T14:07:41+00:00

If you go to a new record in the subform, there is nothing to synchronize. So you could add the following line at the beginning of the On Current event procedure of the subform:

    If Me.NewRecord Then Exit Sub

or alternatively

    If IsNull(Me!MtceID) Then Exit Sub

Was this answer helpful?

0 comments No comments

13 additional answers

Sort by: Most helpful
  1. HansV 462.6K Reputation points
    2011-11-05T15:53:59+00:00

    Do you have code for the On Current event of the main form?

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-11-05T15:33:33+00:00

    That worked fine. But I'm unable to get the main form to go to a new record.

    Not sure about this.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2011-11-05T12:26:24+00:00

    Both forms are based on the same table. It's the only way I found that I can select a row in the datasheet subform and have the main form go to that record. I've tried [placing the ID field in the LInk Child and Link Master fields but but didn't work.

    Was this answer helpful?

    0 comments No comments
  4. HansV 462.6K Reputation points
    2011-11-05T11:50:56+00:00

    You shouldn't use code to synchronize the subform with the main form, but set the Link Child Fields and Link Master Fields properties of the subform control on the main form instead.

    Was this answer helpful?

    0 comments No comments