Add and modify without exit the form

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

Guest

Hi,
I want to know if it is possible to add a film number in a record, and
without exit the form, switch in modify mode to add data in other tables such
actors that are in this particular film. If it's possible, how can I do it ?
I'll be happy even if you have only a general answer.
Thanks.
 
If there is a relationship between the underlying tables, you may be able to
build a subform to add the data to subsequent tables, if not, you can
probably built a recordset and use AddNew. Here's some aircode:

Sub cmdAdd_Click()
On Error GoTo Error_Handler

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("tblNameHere", , dbAppendOnly)

With rst
.AddNew
!ActorName= Me.txtActorName
!OtherField = Me.txtOtherData
.Update
.Close
End With

Exit_Here:
rst.Close
Set rst = Nothing
Set db = Nothing

Error_Handler:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Here
End Sub
 
There is relationship with other tables. The problem is that I can't update
the data in other tables (such actors) because the record containing the film
number (the field in relation) must be added to the film table before. This
is where I'm stuck.
 
Moff said:
Hi,
I want to know if it is possible to add a film number in a record, and
without exit the form, switch in modify mode to add data in other tables such
actors that are in this particular film. If it's possible, how can I do it ?
I'll be happy even if you have only a general answer.
Thanks.


Sure. These things are normally accomplished using subforms.

You would first create a form whose Data Source is the film table. Then
create another form whose Data Source is the actor table. Finally, open up
the Film form in design view and add the Actor form into it as a sub form.
 
To simplify, I want to add a film number in a record, and without exit the
form, switch in modify mode to modify other fields of this record. Is it
possible ?
 
Moff said:
To simplify, I want to add a film number in a record, and without exit
the
form, switch in modify mode to modify other fields of this record. Is it
possible ?

Yes. You can do it with the NotInList event of a combo box. You can also so
it with unbound forms. The code I wrote in the earlier post will also work
with unbound an form.
 
Back
Top