Can't create new record in subform

D

dee

I have a main form "FmLeads".
It contains a field "Salesman" which has an 'After Change' Event
Procedure.

The Main form "FmLeads", contains a subform "FmDispoHistory". It
displays all historic Salesman changes in continuous form format.

It is related to with ONE "FmLeads" record -->> MANY "FmDispoHistory"
records via an ID field.

I need the Salesman 'After Change' Event Procedure on the main form to
add a new record to the "FmDispoHistory" subform, and then to assign
the value of the "Salesman" field from the main form to the "Salesman"
field in the subform.

Could someone help me with a few lines of VB code that can do tjhis?
Thank You
 
S

Steve Schapel

Dee,

I assume you mean the After Update event - there is no 'After Change'?

While on the topic of terminology, forms don't have fields. They have
controls, which may or may not be bound to a field in the form's
underlying record source table or query.

In the case of your Salesman control, am I correct in my guess that it
is a combobox? And am I correct in my guess that it is unbound? And am
I correct in my guess that the Salesman data is a text data type? If
so, the code might look something like this...

CurrentDb.Execute "INSERT INTO DispoHistory ( ID, Salesman )" & _
" VALUES ( " & Me.ID & ", " & """" & Me.Salesman & """" & " )",
dbFailOnError
Me.FmDispoHistory.Requery

If something like this doesn't do it for you, please post back with
further details, with specific examples.
 

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