Creating a new Subform record - problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working on an event management database. On one form, we have the master
record, "Event", with a linked sub-table "IndEvent".

I have a form where you add new events, and fill in the fields specifying
the individual event happenings. I have a button where I wish to allow them
to start adding additional individual events linked to the master event (for
example, you have a conference, and you have multiple presentations
thorughout the day).

Initially, I tried programming the button on the subform using the
"DoCmd.GoToRecord" method, but as I've discovered here, Access has trouble
because it doesn't look at the sub-forms as being open forms, per se.

I found some coding, but nothing works:

1) RecordSet.AddNew - along with other coding to define the recordset and
refocus it, as found in other threads here, seems to do nothing when I push
the button.

2) "Dim MyDB As DataBase, MyRec As Recordset

Set MyDB = CodeDb
Set MyRec = MyDB.openrecordset("select * from IndEvent where EventID = " &
Me.EventID)

MyRec.AddNew
MyRec.Update
Me.Requery

End Sub"

I get an error when it chokes on the DataBase type, saying it's an undefined
user-defined type. I went to check the box referencing the MS ADO 3.6
library, but it's not an installed option.

Any other suggestions? Many, if not most of the users aren't Access saavy,
so I want this button to be there instead of just using navigation arrows,
which especially become confusing to my users with nested sub-forms.

Any solutions you have tried or suggestions would be welcome. If my details
are at all confusing, let me boil it down -

How do I code a button to add a new record to a table on a sub-form (keeping
in mind I allow a single record form view only on the sub-form)?
 
Never mind. I guess I don't understand why people came on here and said that
the problem with the error message "{subform name} form not open" is a
problem of the form not being recognized.

My original coding -

"DoCmd.GoToRecord(acDataForm,Me.Name,acNewRec)" - was programmed into the
subform event button and created the error message of the subform not being
open.

New coding that works just fine -

"DoCmd.GoToRecord , , acNewRec"

Sometimes the solution is simple, yet not intuitively apparent, I guess.
 

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