Close form

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

I'd have a single form that contains n number of records.
After the user enters data into the nth record, I'd like
the form to close.

I'm using the code below which works sometimes, but more
often than not fails. It is in the after update event of
the unbound text box where the user is entering data (this
is the only entry field on the form.)

Any help would be appreciated!

Thanks in advance,

Jason

Set rst = Me.RecordsetClone
rst.MoveNext
If rst.EOF Then
DoCmd.Close acForm, "frmTestByIPC2"
End If
rst.Close
Set dbs = Nothing
 
Hi Jason,

You need to set the bookmark of the recordsetclone to match the bookmark of
the recordset - otherwise the starting point with the recordsetclone is
fairly arbitrary. Also, you can use the With..End With construct and
eliminate the rst Variable:

with Me.RecordsetClone
'set the bookmark to the form's current record
.bookmark=me.bookmark
.MoveNext
If .EOF Then
DoCmd.Close acForm, "frmTestByIPC2"
End If
.Close
end with
 
Lots of help from you today - thanks again Sandra!

Jason
-----Original Message-----
Hi Jason,

You need to set the bookmark of the recordsetclone to match the bookmark of
the recordset - otherwise the starting point with the recordsetclone is
fairly arbitrary. Also, you can use the With..End With construct and
eliminate the rst Variable:

with Me.RecordsetClone
'set the bookmark to the form's current record
.bookmark=me.bookmark
.MoveNext
If .EOF Then
DoCmd.Close acForm, "frmTestByIPC2"
End If
.Close
end with

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I'd have a single form that contains n number of records.
After the user enters data into the nth record, I'd like
the form to close.

I'm using the code below which works sometimes, but more
often than not fails. It is in the after update event of
the unbound text box where the user is entering data (this
is the only entry field on the form.)

Any help would be appreciated!

Thanks in advance,

Jason

Set rst = Me.RecordsetClone
rst.MoveNext
If rst.EOF Then
DoCmd.Close acForm, "frmTestByIPC2"
End If
rst.Close
Set dbs = Nothing

.
 
You're welcome :-)

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Lots of help from you today - thanks again Sandra!

Jason
-----Original Message-----
Hi Jason,

You need to set the bookmark of the recordsetclone to match the
bookmark of the recordset - otherwise the starting point with the
recordsetclone is fairly arbitrary. Also, you can use the With..End
With construct and eliminate the rst Variable:

with Me.RecordsetClone
'set the bookmark to the form's current record
.bookmark=me.bookmark
.MoveNext
If .EOF Then
DoCmd.Close acForm, "frmTestByIPC2"
End If
.Close
end with

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I'd have a single form that contains n number of records.
After the user enters data into the nth record, I'd like
the form to close.

I'm using the code below which works sometimes, but more
often than not fails. It is in the after update event of
the unbound text box where the user is entering data (this
is the only entry field on the form.)

Any help would be appreciated!

Thanks in advance,

Jason

Set rst = Me.RecordsetClone
rst.MoveNext
If rst.EOF Then
DoCmd.Close acForm, "frmTestByIPC2"
End If
rst.Close
Set dbs = Nothing
 
Back
Top