Data Entry Property - Forms

J

Jay

Hi,

If I set the Data Entry property to YES in Form Design View, this causes the
form to open with empty fields, ready for input to the next available
record. However, what if I want the form to open like that sometimes but
not like that at other times?

I want a command button to open the form for data entry & a command button
to open the form *not* for data entry (so it opens at the first record to
enable the user to view & scroll through the records with the record
selectors).

How can I do this? Have one button open the form with the Data Entry
property set to YES and the other button open the same form but with the
Data Entry property set to NO?

Any help would be greatly appreciated.

Many TIA.

-Jay-
 
B

Brian Bastl

Jay,

you only need the one form with its Data Entry property set to 'No', and two
command buttons if you choose to do it this way. You'd then use the
following code to open the form in Data Entry mode:

DoCmd.OpenForm "frmMyForm",,,,acFormAdd

HTH,
Brian
 
J

Jay

Thanks for your help Barry, but I can't get it to work. I tried your code in
the OnCLick property of the button and simply replaced "frmMyForm" with the
form name, but I get a "Can't find the macro" error. So I created an
openForm macro & put that in the OnClick property and tried tagging on the
,,,,acFormAdd but no joy. Am I missing something? Sorry to be a pain:)

Regards
-Jay
 
B

Brian Bastl

Jay,

Having never used macros in Access, I'd suggest you lose the macro and place
the code in the button's OnClick event procedure. To do this, open the
property sheet for your command button, click on the events tab, click on
the blank space to the right of 'OnClick', select [Event Procedure] using
the dropdown arrow, and click the ellipse button to the far right [...].
That will launch the VBA editor with your cursor positioned within the
correct procedure. Then add the 'DoCmd.OpenForm ....."

Yes, change frmMyForm to the name of your form

Example:
Private Sub YourCommandButton_Click()
DoCmd.OpenForm "frmMyForm",,,,acFormAdd
End Sub

HTH,
Brian
 
J

Jay

Brian,

Many thanks for that...it works a treat. It's also helped give me an
insight into how VBA works. I guess I'm like most Access novices & have
avoided it:) What exactly does the four commas signify in the statement
structure?

Thanks again,

Jason

Jay,

Having never used macros in Access, I'd suggest you lose the macro and place
the code in the button's OnClick event procedure. To do this, open the
property sheet for your command button, click on the events tab, click on
the blank space to the right of 'OnClick', select [Event Procedure] using
the dropdown arrow, and click the ellipse button to the far right [...].
That will launch the VBA editor with your cursor positioned within the
correct procedure. Then add the 'DoCmd.OpenForm ....."

Yes, change frmMyForm to the name of your form

Example:
Private Sub YourCommandButton_Click()
DoCmd.OpenForm "frmMyForm",,,,acFormAdd
End Sub

HTH,
Brian


Jay said:
Thanks for your help Barry, but I can't get it to work. I tried your code in
the OnCLick property of the button and simply replaced "frmMyForm" with the
form name, but I get a "Can't find the macro" error. So I created an
openForm macro & put that in the OnClick property and tried tagging on the
,,,,acFormAdd but no joy. Am I missing something? Sorry to be a pain:)

Regards
-Jay
 
D

Douglas J. Steele

The actual syntax for the OpenForm method is:

DoCmd.OpenForm formname[, view][, filtername][, wherecondition][,
datamode][, windowmode][, openargs]

Parameters in square brackets are optional. By putting the four commas in,
you're indicating that you're trying to pass the 1st parameter (formname)
and the 5th parameter (datamode). An alternative way to write that would be
to use the name of the parameter, followed by := (colon, equal sign), then
the value that's applicable for that paramter:

DoCmd.OpenForm FormName:="frmMyForm", DataMode:=acFormAdd

or, more simply,

DoCmd.OpenForm "frmMyForm", DataMode:=acFormAdd


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Jay said:
Brian,

Many thanks for that...it works a treat. It's also helped give me an
insight into how VBA works. I guess I'm like most Access novices & have
avoided it:) What exactly does the four commas signify in the statement
structure?

Thanks again,

Jason

Jay,

Having never used macros in Access, I'd suggest you lose the macro and
place
the code in the button's OnClick event procedure. To do this, open the
property sheet for your command button, click on the events tab, click on
the blank space to the right of 'OnClick', select [Event Procedure] using
the dropdown arrow, and click the ellipse button to the far right [...].
That will launch the VBA editor with your cursor positioned within the
correct procedure. Then add the 'DoCmd.OpenForm ....."

Yes, change frmMyForm to the name of your form

Example:
Private Sub YourCommandButton_Click()
DoCmd.OpenForm "frmMyForm",,,,acFormAdd
End Sub

HTH,
Brian


Jay said:
Thanks for your help Barry, but I can't get it to work. I tried your
code in
the OnCLick property of the button and simply replaced "frmMyForm" with the
form name, but I get a "Can't find the macro" error. So I created an
openForm macro & put that in the OnClick property and tried tagging on
the
,,,,acFormAdd but no joy. Am I missing something? Sorry to be a pain:)

Regards
-Jay

On 13/5/06 01:42, in article (e-mail address removed),
"Brian

Jay,

you only need the one form with its Data Entry property set to 'No',
and two
command buttons if you choose to do it this way. You'd then use the
following code to open the form in Data Entry mode:

DoCmd.OpenForm "frmMyForm",,,,acFormAdd

HTH,
Brian


Hi,

If I set the Data Entry property to YES in Form Design View, this causes
the
form to open with empty fields, ready for input to the next available
record. However, what if I want the form to open like that sometimes but
not like that at other times?

I want a command button to open the form for data entry & a command button
to open the form *not* for data entry (so it opens at the first record to
enable the user to view & scroll through the records with the record
selectors).

How can I do this? Have one button open the form with the Data Entry
property set to YES and the other button open the same form but with the
Data Entry property set to NO?

Any help would be greatly appreciated.

Many TIA.

-Jay-
 

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