Question Help on function keys and gotonextrecord

dean

Registered User.
Local time
Today, 02:48
Joined
Sep 7, 2009
Messages
13
Hi !

I am a new member of this forum and a newbie in Access. I joined this forum to ask for help.

I have a form that has command buttons for addrecord, first, previous, next and last.

I have no idea on how to solve this but what I want to achieve is when I click the next button, it will only go to the next record but NOT/CREATE to/a the new record. what happens is that when I input new data and click next, it acts as if I add it.

Also I would like to know who to use function key such as F10 such that when I press F10 it will close form or add record.

TIA
 
Firstly Welcome to the forum.

In your Go To Next button insert the following code;
Code:
    If Me.CurrentRecord = DCount("*", "TBL_YourTableName") Then
         MsgBox "Last record"
         Exit Sub
    End If
    
    
    DoCmd.GoToRecord , , acNext

For the second question with your form in design view set it's Key Preview property to Yes (you will find this on the Event Tab just below On Key Press. Now in the Form's On Key Down event insert the following;
Code:
    If KeyCode = vbKeyF10 Then
         Me.Refresh 
         DoCmd.Close
    End If
If you do not want the form to store unsaved data before closing remove the Me.Refresh command.
 
thanks for this reply.
 

Users who are viewing this thread

Back
Top Bottom