Unbound Text Box in Subform

G

Guest

I have a program with a parent form and two subforms (subform A and subform
B), each subform is located under a separate tab. In subform B I have an
unbound txt box (txtweight) and also a command button to run a report. In
subform A I have a ‘weight’ field. I’ve written code so that if a person
enters a weight in subform B, it’s automatically recorded in the weight field
of subform A. This works well and if I go from subform B to subform A and
then back to subform B to print the report, this works fine too. My problem
is that if I enter the weight on subform B and then immediately press the
button to print my report, the weight has not yet been written to the subform
A control source for weight and, consequently, doesn’t show up on the report.
I’ve played around with Me.Requery, Me.Refresh, wrote a short recordset
program to try to write it to the file, etc.; obviously if one of these
approaches is correct then I must be putting it in the wrong event? Any
words from the wise would be appreciated.
 
M

Marshall Barton

Scott said:
I have a program with a parent form and two subforms (subform A and subform
B), each subform is located under a separate tab. In subform B I have an
unbound txt box (txtweight) and also a command button to run a report. In
subform A I have a ‘weight’ field. I’ve written code so that if a person
enters a weight in subform B, it’s automatically recorded in the weight field
of subform A. This works well and if I go from subform B to subform A and
then back to subform B to print the report, this works fine too. My problem
is that if I enter the weight on subform B and then immediately press the
button to print my report, the weight has not yet been written to the subform
A control source for weight and, consequently, doesn’t show up on the report.
I’ve played around with Me.Requery, Me.Refresh, wrote a short recordset
program to try to write it to the file, etc.; obviously if one of these
approaches is correct then I must be putting it in the wrong event?


You could have told us which event you are using to write
the value ot the field/control on subformA, but I'll assume
that it's subformB txtweight's AfterUpdate event. I think
the issue is that the data in subformA has not been saved to
its RecordSource table. If that's the issue, then use code
in the button's Click event to save the record sin subformA:

With Parent.subformA.Form
If .Dirty Then .Dirty = False
End With
 

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