question about updating fields from main to the subform

G

Guest

hi,
My subform and main form seem to work for the most part, except that when I
want the subform to be in sync with the main form, I hit 'enter'. I
attempted to put some code in the 'exit ' event of the text box which
determines the records displayed. Below is what I tried: I want the client
id in the log (subform) to be set to the clientid in the mainform. So, this
code is in the mainform.

Forms!clients.log.Form!ClientID = Me.ClientID -

can you point me to some examples where this is done? I am just still a
newbie at a this. Many thanks.
 
G

Guest

In the After Update event of the ClientID control on the main form.

Me.log.Form!ClientID = Me.ClientID -

log should be the name of the subform control on your main form. Not the
form that is used as the source object for the subform control.
 
G

Guest

Hi Klatuu,

I see, thanks. I placed it there. I get error messages sometimes, not
always, when I tab to the subform , for example, if I want to see the next
'log' for a particular client. I get error messages as if I were trying to
update the log entry - but I'm not. It says 'violation of primary key,etc...
cannot insert duplicate key in object 'clients'....
I am not sure what to look for - any ideas?
 
G

Guest

:

Well, in fact you are. If your clientId control on the main form is a bound
control, then changing that value will also change the value in the form's
recordset. Because the code is in the After Update event of the client id
control, it is also trying to update the value in the current record in the
subform. If you want to search by client, I would suggest you use a
different unbound control to do that. The combo box is perfect for this sort
of thing.
 
G

Guest

Oh! What I really wanted to do was just display what was there. I guess I
could have just written a query and just populated the fields with results.
Thanks again. It's clear that I don't know enough about this yet.
 

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