open form in add mode

  • Thread starter Thread starter george
  • Start date Start date
G

george

Hi to all and thanks for the support,

I have a list box with family names. When the user clicks
on a name another form opens, FamilyMembers, showing all
the family members. This works fine.

Now I would like to add a button next to the list box with
the following behaviour: If there are records in the list
box the button will be inactive. If there are no records
in the list box the button becomes active and opens the
FamilyMembers form to a new record.

Any help will be greatly appreciated
 
Why not try this code in the family records form:

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub

That will open the form on a new record.

HTH PJB
 
thanks for the reply, but this won't help. I want the form
to open to a new record *only* when there are no entries
in the list box. If there are entries I want to open it
(through the list box click event) to a specific record

george
 
george said:
I have a list box with family names. When the user clicks
on a name another form opens, FamilyMembers, showing all
the family members. This works fine.

Now I would like to add a button next to the list box with
the following behaviour: If there are records in the list
box the button will be inactive. If there are no records
in the list box the button becomes active and opens the
FamilyMembers form to a new record.

Try using this code in the form's Current event:

Me.thebutton.Enabled = (Me.thelistbox.ListCount > 0)

You'll want that line in another place. I'm not sure where,
but it will be any place where you requery the list box
after it's rowsource table has been updated.

To open a form to just a new record, open it with the
DataMode argument set to acFormAdd (see OpenForm method in
Help for details).
 

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

Back
Top