open form event

G

gator

I want to click a button on form1 to open form2 and goto last record so I can
enter an amount. After I key the amount, I want to be able to push Enter
button on keyboard and form2 closes. Can someone help guide me?
 
G

gator

'to open and goto last record

DoCmd.OpenForm "form2"
DoCmd.GoToRecord acActiveDataObject, "form2", acLast

'after amount entered and "Enter" key is pushed

Private Sub field1_AfterUpdate()
DoCmd.Close acForm, "form2"
End Sub
 
S

Stuart McCall

gator said:
I want to click a button on form1 to open form2 and goto last record so I
can
enter an amount. After I key the amount, I want to be able to push Enter
button on keyboard and form2 closes. Can someone help guide me?

Put a command button on your form and set its Default property to Yes. Make
the caption (eg) Ok. In the Click event for the button, close the form:

DoCmd.Close acForm, Me.Name

Such a button will respond to both the enter key and the mouse.
 

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