Access form reset

Askie

New member
Local time
Today, 12:06
Joined
Sep 4, 2012
Messages
5
Hi I am using Access 2007.
Essentially what I am after is how I can get an input form to clear itself upon opening it then, after adding a new record again clearing itself down.

I am relatively new to this so any help will be most appreciated
 
Bob
Sorry but how do I establish whether the form is bound or otherwise?
 
Bob
Sorry but how do I establish whether the form is bound or otherwise?

If your form has a table, query, or SELECT statement in its Record Source property (found in the properties dialog when you open the form in design view and then go to the DATA tab).
 
If your form has a table, query, or SELECT statement in its Record Source property (found in the properties dialog when you open the form in design view and then go to the DATA tab).

Thanks Bob. The form is bound. So therefore the original solution of navigating to new record is the one. Since I would like this to be controlled by a button "Add Record" how do I navigate to new record programatically i.e. Code
Such code would need to give me clear form when I first open it and then again when I finish adding record
 
The code to go to a new record can be
Code:
If Not Me.NewRecord
   DoCmd.RunCommand acCmdRecordsGoToNew
End If

That would go in the form's On Load event and in the click event of the button.

But you can create a new function in a standard module, like this:
Code:
Function NewRec(frm As Form)
   If Not frm.NewRecord Then
      frm.Recordset.AddNew
   End If
End Function

And then you can call that function in both events.

If you put it into the event property of that event you can use

=AddRec

or if you put it in the VBA Window of the event you can just use

AddRec
 
Bob
I've tried the function but cannot get it to work using either of the options (AddRec, =AddRec)
Also noticed that the function is ...NewRec.... so I changed to NewRec instead of AddRec, still no joy:(
 

Users who are viewing this thread

Back
Top Bottom