Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Resolved Question

Help with Macro's

Oct 29, 2011 12:56AM PDT

Hi Everyone,

I'm using microsoft access and i have a simple table called profiles with names, location, etc.

I have built a form to add new records to this table with a button and the onclick event set to new record.

Yet everytime i run the form it just replaces my first record with what i have entered then does not let me enter any new records at all.

I am new to access and macros and don't know much at all, so if its something simple i apologize.

Any help would be appreciated.

Discussion is locked

Cell_Splinter has chosen the best answer to their question. View answer

Best Answer

- Collapse -
Re: on click event
Oct 30, 2011 11:52PM PDT

You don't set the onclick event to make a new record to a button on the form. That already opened with the first record of the table, as you saw.

You set it to a button outside the form to call a VBA-module that opens that form with a new record. The VBA-code is DoCmd.OpenForm myFormName, acNormal, , , acFormAdd

Kees

.

- Collapse -
Or ...
Oct 30, 2011 11:55PM PDT

if you prefer a macro above a VBA module, you call a 1-line macro for OpenForm with the add function in that button you make outside the form. That's the same. The docmd-command in VBA does nothing more than making a temporary macro and execute it.

Kees

- Collapse -
Sorted
Oct 31, 2011 3:15AM PDT

This one worked out nicely..

Thanks Kees