Add data from text box to table

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

Guest

I have a form where users input data. I have one field that is not adding
the information to the table behind it for some reason. Is there a way to
manually add the data to the table, say when the user clicks the command
button to view the report? Is there a line of code that can manually add the
data to the table? Please Help!

Thanks
 
Hi, jped.

The textbox is most likely not bound to your field. Change the Control
Source property of the textbox to the name of the field in the underlying
table. If the field is not in the drop-down list, your form is likely based
on a query that doesn't include this field, rather than the actual table.
Check the form's RecordSource property for the name if it. Add the field to
the query first, and then you can bind the textbox to it.

Hope that helps.
Sprinks
 
Sprinks,

Thanks, I see what you're saying. What I did though was pull the value from
a previous form. The previous form is a form where the user chooses a
vendor, then clicks a command button to open a seperate form to fill out
purchase order information for that vendor. On the second form, I just
pulled over the vendor name so my control source for the text box is:

=[Forms]![frmVendor]!VendorName

I need to take this value somehow and save it in the PurchaseOrder table.
The PurchaseOrder table is linked to the Vendor table in the relationships.
Does this make sense? Can I fix this?

Thanks
 
Yes, you can fix it.
=[Forms]![frmVendor]!VendorName should not be the control source. Put it in
the default value property, and then do what Sprinks said

jped said:
Sprinks,

Thanks, I see what you're saying. What I did though was pull the value from
a previous form. The previous form is a form where the user chooses a
vendor, then clicks a command button to open a seperate form to fill out
purchase order information for that vendor. On the second form, I just
pulled over the vendor name so my control source for the text box is:

=[Forms]![frmVendor]!VendorName

I need to take this value somehow and save it in the PurchaseOrder table.
The PurchaseOrder table is linked to the Vendor table in the relationships.
Does this make sense? Can I fix this?

Thanks

Sprinks said:
Hi, jped.

The textbox is most likely not bound to your field. Change the Control
Source property of the textbox to the name of the field in the underlying
table. If the field is not in the drop-down list, your form is likely based
on a query that doesn't include this field, rather than the actual table.
Check the form's RecordSource property for the name if it. Add the field to
the query first, and then you can bind the textbox to it.

Hope that helps.
Sprinks
 
Thank you. It pulls over the Vendor name to the second form. I'm not sure
if you can help me with this now. I am now getting an error 'You cannot add
or change a record because a related record is required in table
"tblVendors"' I have nothing on this second form that puts information in
the tblVendors table. That is what the first form is based on. Any ideas

I have a filter on so the Vendor Name is displayed in the text box instead
of the VendorID if that has anything to do with it. Hopefully you can help!

Thanks again!

Klatuu said:
Yes, you can fix it.
=[Forms]![frmVendor]!VendorName should not be the control source. Put it in
the default value property, and then do what Sprinks said

jped said:
Sprinks,

Thanks, I see what you're saying. What I did though was pull the value from
a previous form. The previous form is a form where the user chooses a
vendor, then clicks a command button to open a seperate form to fill out
purchase order information for that vendor. On the second form, I just
pulled over the vendor name so my control source for the text box is:

=[Forms]![frmVendor]!VendorName

I need to take this value somehow and save it in the PurchaseOrder table.
The PurchaseOrder table is linked to the Vendor table in the relationships.
Does this make sense? Can I fix this?

Thanks

Sprinks said:
Hi, jped.

The textbox is most likely not bound to your field. Change the Control
Source property of the textbox to the name of the field in the underlying
table. If the field is not in the drop-down list, your form is likely based
on a query that doesn't include this field, rather than the actual table.
Check the form's RecordSource property for the name if it. Add the field to
the query first, and then you can bind the textbox to it.

Hope that helps.
Sprinks

:

I have a form where users input data. I have one field that is not adding
the information to the table behind it for some reason. Is there a way to
manually add the data to the table, say when the user clicks the command
button to view the report? Is there a line of code that can manually add the
data to the table? Please Help!

Thanks
 
I have a form where users input data. I have one field that is not adding
the information to the table behind it for some reason. Is there a way to
manually add the data to the table, say when the user clicks the command
button to view the report? Is there a line of code that can manually add the
data to the table? Please Help!

Thanks

Well, let's fix the textbox instead! What is its Control Source? Is it
the name of a field in the form's table?

To check, open the Form in design view, and view its Properties. Click
the ... icon by the Recordsource property; if Access asks whether you
want to open the recordsource as a query, click yes. Select all of the
fields that should be updated (including this one) and close the query
window, accepting the offer to update the recordsource property.

Then check that the Control Source property of the textbox is indeed
the name of the field.

Adding the value separately is possible but seems like the wrong
solution to this simple problem!

John W. Vinson[MVP]
 
I am not sue, but I think the filter may be causing the problem or the text
box you are showing the name instead of the ID has the control source of the
ID, meaning it is trying to match to the name instead of the ID. for a test,
add another text box for the name, be sure the text box with the ID has the
control source of the ID field in the table and try that.

jped said:
Thank you. It pulls over the Vendor name to the second form. I'm not sure
if you can help me with this now. I am now getting an error 'You cannot add
or change a record because a related record is required in table
"tblVendors"' I have nothing on this second form that puts information in
the tblVendors table. That is what the first form is based on. Any ideas

I have a filter on so the Vendor Name is displayed in the text box instead
of the VendorID if that has anything to do with it. Hopefully you can help!

Thanks again!

Klatuu said:
Yes, you can fix it.
=[Forms]![frmVendor]!VendorName should not be the control source. Put it in
the default value property, and then do what Sprinks said

jped said:
Sprinks,

Thanks, I see what you're saying. What I did though was pull the value from
a previous form. The previous form is a form where the user chooses a
vendor, then clicks a command button to open a seperate form to fill out
purchase order information for that vendor. On the second form, I just
pulled over the vendor name so my control source for the text box is:

=[Forms]![frmVendor]!VendorName

I need to take this value somehow and save it in the PurchaseOrder table.
The PurchaseOrder table is linked to the Vendor table in the relationships.
Does this make sense? Can I fix this?

Thanks

:

Hi, jped.

The textbox is most likely not bound to your field. Change the Control
Source property of the textbox to the name of the field in the underlying
table. If the field is not in the drop-down list, your form is likely based
on a query that doesn't include this field, rather than the actual table.
Check the form's RecordSource property for the name if it. Add the field to
the query first, and then you can bind the textbox to it.

Hope that helps.
Sprinks

:

I have a form where users input data. I have one field that is not adding
the information to the table behind it for some reason. Is there a way to
manually add the data to the table, say when the user clicks the command
button to view the report? Is there a line of code that can manually add the
data to the table? Please Help!

Thanks
 
Thank you. It pulls over the Vendor name to the second form. I'm not sure
if you can help me with this now. I am now getting an error 'You cannot add
or change a record because a related record is required in table
"tblVendors"' I have nothing on this second form that puts information in
the tblVendors table. That is what the first form is based on. Any ideas

I have a filter on so the Vendor Name is displayed in the text box instead
of the VendorID if that has anything to do with it. Hopefully you can help!

I think what's happening is that you're trying to store the vendor
*name* into the VendorID field. You'll only be able to store a valid
VendorID in the field; perhaps you're setting the default value
property to the human-readable name, instead of the numeric ID.

John W. Vinson[MVP]
 
John,

Thanks! That worked! And thank you to everyone else for their help! I
actually used parts of other people's answers to display vendor name, ID etc.
Thanks again! I may be making another post about finding a specific order
based on a users input. If you have any general help on that, please let me
know.

Thanks again!
 
Back
Top