Open to next open record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

First I'll let you know that I'm running Access 97. I have a form that has a
subform within it used for inspecting parts. When an inspector opens the main
form they do a search for the part number they are looking for. When they
find the part number they want, and they say "ok" I would like the subform to
open to the next available record. This way they don't have to toggle to the
last record or risk entering data over the old data.
Any help would be greatly appreciated.
 
First I'll let you know that I'm running Access 97. I have a form that has a
subform within it used for inspecting parts. When an inspector opens the main
form they do a search for the part number they are looking for. When they
find the part number they want, and they say "ok" I would like the subform to
open to the next available record. This way they don't have to toggle to the
last record or risk entering data over the old data.
Any help would be greatly appreciated.

A couple of ways to do this:

One would be to set the Subform's Data Entry property to True. This
will make it display *only* the blank new record (and not let you see
the existing ones).

Another is to put code in the Subform's Open event:

Private Sub Form_Open(Cancel as Integer)
DoCmd.GoToRecord, , acNewRecord
End Sub


John W. Vinson[MVP]
 
Sorry this took so long, but I tried to add the code to the open event, but
get the following error
"Run-time error '2105'
you can't go to the specified record.
you may be at the end of a recordset"
Then the option to Debug or End.
Any help with this would be appreciated. I also tried to change the Data
Entry to "yes", but then previous records cannot be seen in the form (used to
see past data checks).
 
im not sure which error this is but from my experience if you try to goto
newrecord programatically when youre in a new record you get an error so you
might first try something like

if not me.newrecord then....

or if you have an autonumber field, which is null until entry of first char
to record, you can also try

if isnull([myANField]) then...
 
I'm still getting the error message when I open the main form.

YisMan said:
im not sure which error this is but from my experience if you try to goto
newrecord programatically when youre in a new record you get an error so you
might first try something like

if not me.newrecord then....

or if you have an autonumber field, which is null until entry of first char
to record, you can also try

if isnull([myANField]) then...
--
Thankfully, YisMan


Sheila said:
Sorry this took so long, but I tried to add the code to the open event, but
get the following error
"Run-time error '2105'
you can't go to the specified record.
you may be at the end of a recordset"
Then the option to Debug or End.
Any help with this would be appreciated. I also tried to change the Data
Entry to "yes", but then previous records cannot be seen in the form (used to
see past data checks).
 
Back
Top