G
Guest
I have a form where the record source is a table [purchase requisition]. In
the form_open procedure, i create a filter based on the username. If no
records are selected by the filter, I want to create a new one. When I test
the form with a username that has no records in the file, instead of creating
a new record, it gives the error "you can't go to the specified record".
form.allowadditions is true, form.dataentry is true here. and
form.allowedits is true. The recordset type is dynaset. Here is my
procedure:
Private Sub Form_Open(Cancel As Integer)
' change record source filter depending on who the user is
If CurrentUser = "jdouglas" Or CurrentUser = "dcostello" Then
Me.Filter = "STATUS IN ('S','P','A')"
Else
Me.Filter = "SUBMITTER = CURRENTUSER"
End If
Me.FilterOn = True
'if no records meet the criterion, then create a new one
If Me.Recordset.RecordCount = 0 Then
Me.DataEntry = True
DoCmd.GoToRecord , , acNewRec
End If
End Sub
I have no trouble using docmd to add a record (via a button on the form) if
the user already has a record.
I would be most appreciative is someone could give me some hints as to why
this is happening or how to track it down.
Thanks!
the form_open procedure, i create a filter based on the username. If no
records are selected by the filter, I want to create a new one. When I test
the form with a username that has no records in the file, instead of creating
a new record, it gives the error "you can't go to the specified record".
form.allowadditions is true, form.dataentry is true here. and
form.allowedits is true. The recordset type is dynaset. Here is my
procedure:
Private Sub Form_Open(Cancel As Integer)
' change record source filter depending on who the user is
If CurrentUser = "jdouglas" Or CurrentUser = "dcostello" Then
Me.Filter = "STATUS IN ('S','P','A')"
Else
Me.Filter = "SUBMITTER = CURRENTUSER"
End If
Me.FilterOn = True
'if no records meet the criterion, then create a new one
If Me.Recordset.RecordCount = 0 Then
Me.DataEntry = True
DoCmd.GoToRecord , , acNewRec
End If
End Sub
I have no trouble using docmd to add a record (via a button on the form) if
the user already has a record.
I would be most appreciative is someone could give me some hints as to why
this is happening or how to track it down.
Thanks!