Adding new record

B

Bobk

I have a continuous form where all the data is displayed for bookings. The
data is in tabular form with one line of data displayed for each record. The
user can scroll up and down or search records. The job number of each booking
is the key. I have a button for "New" which sends the user to the bottom of
the file and a blank line where the new record can be entered. The file is
displayed with the earliest booking at the top of the list to the latest
(last) booking at the end of the list. I want to reverse the order of the
list with the most recent entry appearing at the top and be able to enter new
records at the top of the list. Is there a way to do this?
 
B

Bobk

I have done that, but when I hit the "New" button it goes to the bottom of
the list and presnts a blank line ready for entry of a new record. I want to
be able to enter the new record at the top of the list where the list is
sorted with the latest record displayed at the top of the list. The code
behind the "New" button is:

Private Sub Command33_Click()
On Error GoTo Err_Command33_Click

DoCmd.GoToRecord , , acNewRec

Exit_Command33_Click:
Exit Sub

Err_Command33_Click:
MsgBox Err.Description
Resume Exit_Command33_Click

End Sub

I would like this to work like email with the latest entry always at the top
of the list.
 
J

Jim Ory

Depending on how you are entering data, this may work for you. I have a
similar form that I enter events and have the latest entry be on the first
line.

I always enter a date of the event first and it is the present date. If it
is wrong I can go back and adjust it if necessary.

Here is the code, without the error correction:

DoCmd.GoToRecord , , acNewRec
Me.dteDate = Now()
DoCmd.Requery

This puts the line at the top to finish entering data. Assuming that the
query is sorting in descending order.
 
B

Bobk

Sorry for the delayed response. I had to work on another project. Your idea
is great. I have a key that is the job number assigned to the booking so I
used the following code:
DoCmd.GoToRecord , , acNewRec
Me.bkjobno = DMax("bkjobno", "qryBookings") + 1
DoCmd.Requery
When the bookings are sorted in descending order the last entry appears at
the top of the list . The above code automatically assigns the next job
number at the top of the list where the user can enter the necessary data. It
works great.

Thanks for the help!
 
J

Jim Ory

Great! Glad that I could help.
--
Jim Ory


Bobk said:
Sorry for the delayed response. I had to work on another project. Your idea
is great. I have a key that is the job number assigned to the booking so I
used the following code:
DoCmd.GoToRecord , , acNewRec
Me.bkjobno = DMax("bkjobno", "qryBookings") + 1
DoCmd.Requery
When the bookings are sorted in descending order the last entry appears at
the top of the list . The above code automatically assigns the next job
number at the top of the list where the user can enter the necessary data. It
works great.

Thanks for the help!
 

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