I have a data entry form that I want to go to a new record on opening. It works except in the instance when there are no records at all. I would like to do something like if recordcount >0 then go to new record.
If I'm on the right track I need to set the recordset to something in the second line below, but, I'm unclear on the syntax.
To just go to a new record when the form is opened I use:
Private Sub Form_Open(Cancel As Integer)
Me.Filter = "[compliance sample] = False"
Me.FilterOn = True
DoCmd.RunCommand acCmdRecordsGoToNew
End Sub
However, this won't work if there are no existing records.
I'm thinking something like:
Private Sub Form_Open(Cancel As Integer)
Set rst = qdf.OpenRecordset
Me.Filter = "[compliance sample] = False"
Me.FilterOn = True
If rst.RecordCount > 0 Then DoCmd.RunCommand acCmdRecordsGoToNew
End Sub
It doesn't like the second line and I really don't know VBA very well.
Can anyone help?
Thanks in advance
If I'm on the right track I need to set the recordset to something in the second line below, but, I'm unclear on the syntax.
To just go to a new record when the form is opened I use:
Private Sub Form_Open(Cancel As Integer)
Me.Filter = "[compliance sample] = False"
Me.FilterOn = True
DoCmd.RunCommand acCmdRecordsGoToNew
End Sub
However, this won't work if there are no existing records.
I'm thinking something like:
Private Sub Form_Open(Cancel As Integer)
Set rst = qdf.OpenRecordset
Me.Filter = "[compliance sample] = False"
Me.FilterOn = True
If rst.RecordCount > 0 Then DoCmd.RunCommand acCmdRecordsGoToNew
End Sub
It doesn't like the second line and I really don't know VBA very well.
Can anyone help?
Thanks in advance