Access a button from another form

A

Ac

Hello,

I created the View and Edit two forms. The first form displays all records
from a table and second form is for editing the record which includes Add,
Save and Delete buttons on it. User could view the record from view form, if
the record does not exit, he will add this record through the Edit form. I
would like to have a button on the View form, called New, when the user
clicks on New button, it will open the Edit form and access the Add button,
(provide the same function as the user clicking on the Add button on the Edit
form). How could I write code for New button? Thanks!
 
C

CW

I'm far from an expert but you could use the Command Button Wizard to create
a button on the View form, with the action being to Open a Form, and the
form being your Edit form.
HTH
CW
 
W

Wayne-I-M

Hi

CW is correct but depends on what you want to do when you arrive at the
EditForm (ie. after editing or adding a new record due you want to go to
another record,etc)
you have not gien any details of this


You could use
Private Sub ButtonName_Click()
DoCmd.OpenForm "EditFormName", acNormal, "", "", acFormAdd, acNormal
End Sub

If this is not what you are looking for post back with details of what you
want to do when you open the edit form
 
C

CW

I don't understand that. You said that there was an Add button on your Edit
form. So once you have got to the Edit form, can't you use that button? Why
do you need another step?
 
W

Wayne-I-M

You use this OnClick of a button on your 1st form. This will open the 2nd
form on a new record. You could just set the OnOpen event of form 2 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