GoToRecord command

L

Lauren B

I have a database where the first page that appears when it is opened is a
blank data entry page where the user can input customer information. I have
coded the page so that it always opens to a new entry by using:
"DoCmd.GoToRecord , , acNewRec" in the On Open properties.

I have a command button on this main data entry page that allows the user to
go to a search page and ultimately input information to filter the database
entries. Upon performing this search, the user is taken back to the data
entry form and it is only displays the appropriate entries based on the
filter. The problem is, the form is opening blank because of the GoToRecord
command.

Is there a way to write the code so that when the user first opens the
database they are taken to a blank entry but when they perform a search
(place a filter on the information) the form opens at the first record?

Thank you in advance for any assistance.

LB
 
A

Allen Browne

When you OpenForm for the search, pass a value in the OpenArgs.

In the form's Open event, check the OpenArgs, and don't go to the new record
if it was opened for a search.
 
N

Nikos Yannacopoulos

Lauren,

It will take some modification in the code in the search form which
imposes the filter, to set focus to the original form and go to the
first record, before the search form is closed. Pls post that code.

Nikos
 
R

Rick Brandt

Lauren said:
I have a database where the first page that appears when it is opened
is a blank data entry page where the user can input customer
information. I have coded the page so that it always opens to a new
entry by using: "DoCmd.GoToRecord , , acNewRec" in the On Open
properties.
I have a command button on this main data entry page that allows the
user to go to a search page and ultimately input information to
filter the database entries. Upon performing this search, the user
is taken back to the data entry form and it is only displays the
appropriate entries based on the filter. The problem is, the form is
opening blank because of the GoToRecord command.

Is there a way to write the code so that when the user first opens the
database they are taken to a blank entry but when they perform a
search (place a filter on the information) the form opens at the
first record?
Thank you in advance for any assistance.

I personally don't like the GoToNew method as it is inefficient to load all of
the records in the form's RecordSource just because the user "might" want to
navigate backwards. Much better is to open the form in DataEntry mode and then
if they need to see other records give them a filtering mechanism for doing so.
This allows for the form to load the minimum number of records to support what
the user is doing (always a good strategy).

You're 90% of the way there because you have already put in the method for
filtering to a specific record. Just remove the GoToNew code from your form and
instead modify the OpenForm method to use acFormAdd when you want to go to a new
record.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top