Controls in forms

B

Bill

How do I add a control button that will open another form in "add" mode
rather than edit?
 
F

fredg

How do I add a control button that will open another form in "add" mode
rather than edit?

Set the Click event of the command button to:

DoCmd.OpenForm "FormName", , , , acFormAdd
 
F

fredg

All it did was come up with a message that it couldn't find the object 'DoCmd'

That offers us no help at all.
Did you change "FormName" to whatever your actual form name is?
Please copy and paste the full exact click event code into a reply
message.
 
D

Dirk Goldgar

Bill said:
Here is what I typed DoCmd.OpenForm "Tenants Move In". . . .acFormAdd


I see you have periods instead of commas. That would certainly be an error.

Did you type that directly into the button's On Click event property (that
would be an error), or did you create an event procedure and put this line
of code inside that event procedure (that would be the right way to do it)?
 
F

fredg

Here is what I typed DoCmd.OpenForm "Tenants Move In". . . .acFormAdd

That's not what I suggested.
You have used dots in place of commas.
The correct syntax is:
DoCmd.OpenForm "FormName", , , , acFormAdd

That's 4 commas after "FormName"
Look up, in VBA help, the OpenForm method for the correct syntax.
 
L

Linq Adams via AccessMonster.com

"All it did was come up with a message that it couldn't find the object
'DoCmd'"

Making the mistake with using periods instead of commas should have popped up
a "syntax error" message, but I don't think Access ever got that far!

Access stating it "couldn't find the object 'DoCmd'" suggests to me that the
OP probably has a missing reference that causing Access to error out.

The periods do, of course, also need to be replaced with commas.
 
D

Dirk Goldgar

Linq Adams via AccessMonster.com said:
"All it did was come up with a message that it couldn't find the object
'DoCmd'"

Making the mistake with using periods instead of commas should have popped
up
a "syntax error" message, but I don't think Access ever got that far!

Access stating it "couldn't find the object 'DoCmd'" suggests to me that
the
OP probably has a missing reference that causing Access to error out.


If Bill put the statement directly into the On Click property of the command
button, then clicking the button would give the error message "<database
name> can't find the macro 'DoCmd.'" My guess is that this is what has
happened.
 
L

Linq Adams via AccessMonster.com

Good point, Dirk! I hadn't even considered that! Be nice to get some feedback
from the OP.
 

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