display and store values in a textbox

G

Guest

I want to display the Cost Centre in a text box on a data entry from and when
the user saves the record, I want it to be recorded in the relevant field.
This Cost Centre is selected from a combo box on a login form and it is being
passed on to the text box of the data entry form.

I know that this topic has been discussed previously and usually the
inquirers are adviced to use a subform or not to re-save the data. But in my
case both options are not possible.

I set up a dummy text box and used the following code to write data to the
relevant field.(with control source of txtDummy set to the relevant field in
the table). However, it doesn't seem to work.

Private Sub Form_BeforeUpdate(Cancel as Integer)
Me!txtDummy = Me!txtCostCentre
End Sub

I tried to use .text and .value properties of the control to do it but it
doesn't seem to write the value to the table. I get an error message saying
the field cannot have a null value because I have set 'required' to true.

Please help me on this. I am desperate and wasted about two days trying to
get around this problem.

Thanks
Toyfixer
 
G

Guest

ToyFixer,

If I understand your situation correctly, you are trying to have the value
in the "txtCostCentre" control to be assigned to be the value fo the
"txtDummy" control. From your description, it appears that these controls
are on different forms.

If this is true, then you will need to provide the complete identification
for the control on the other form. Something like:

Forms!formNameHere!txtDummy = me.txtCostCentre
 

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