open form event

  • Thread starter Thread starter gator
  • Start date Start date
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?
 
'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
 
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.
 
Back
Top