Adding a new record to a subform from a dialog form

G

Guest

Hello,

I have a main form with events and a subform with bookings
for each event. There's a button on the main form to add a
new person's details which opens up a dialog form. A
button on this dialog runs and event procedure which saves
the new details and assigns the values to the booking
subform, but if the 'current record' is not a new one (ie
the cursor was in an existing booking record) then that
record gets overwritten with the new details. I've tried
using the GoToRecord method to make a new record active
before assigning the values to the booking subform:

DoCmd.GoToRecord acDataForm, "FrmIndAttendSub", acNewRec

but I keep getting a message saying that the subform isn't
open even though it obviously is (I've tried a macro as
well but get the same result).

I've also tried using GoToControl to make the subform
active (the Immediate Window tells me that the main event
form is the active one at this point in this event
procedure). IsOpen doesn't seem to work during debuging
and trying IsLoaded alwys seems to return False (for any
form name).
Yours frustratedly

Sue
 
G

Guest

You can do it by form code

In the routine called by the event

- add a new record in the subform recordset, usiong sql instruction

CurrentDb.Execute "Insert ......

or by an openrecordset an then addnew - update methods

- call the refresh

<MainForm>.<subformcontrol>.form.Requer


I hope it will works well ..

Silvia .... from Venic
 

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