Command button to put subform into "new record" mode?



Lots of questions from me today.

I have a subform that displays information from tblproject based on controls
in the main form. However, the user wants the option to add a new record in
addition to viewing/updating the record they might select.

Right now there is a listbox in the main form that controls what project
record is displayed in the subform. How would I write a button that would
basically have the subform add a new record (not open a new form) and
disregard what is in that listbox?

This may make no sense. . .so let me know if I need to clarify.

Jeanette Cunningham

Hi Piperlynne,
an easy way to do this is to show the navigation buttons for the subform.
User can click the new record button to add a new record - this will work
unless the subform's record source is non-updateable - if that is the case,
the new record button will be greyed out.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


I have the command buttons on the subform and they work. But. . .(always a but)
The ProjectID (primary key and child link to the main form) is not clearning
out when I hit the new record button. (Used the wizard to create it) Any

Jeanette Cunningham

You are using a search form to show records in the subform.
The listbox and other search controls are used to show matching records in
the subform.
I will assume that the listbox is unbound.

What sort of record are you adding and what table are you adding it to?
For example, are you adding a new project, are you adding a new project to
the project table, are there any other tables that require an entry before
you can add a related project?

If both the main form and the subform were based on tblProject, then you
could set all the search controls to null in the main form and reset the
record source of the subform to remove any filters (if using a filter) or
remove any where clause if this how you are filtering the subform.
Then you could add a new project record.

In other words, what you can do in your forms and how you can do it depends
very much on the tables in your database. This is the information we need
before we can advise.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

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