Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to save certain fields from form to table

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi All,

I am a beginner and I want to know if it is possible to save just few fields from a data entry from to table.Right now the save command button is trying to save all the fields on the form to the table ,but is giving error since certain fields in the table are already filled with data from other data entry forms.
Any help is appreciated.
Thanks,
Shalini.
 
Shalini,

Sounds like you may not have your tables and forms set up correctly. A table is designed to do nothing but hold data. Queries let you ask questions about your data and/or help you to combine data to provide a source of information for reports, or provide a source for data entry via forms. Data is typically entered/added to a table(s) via forms. What is saved to a table from data entry on a form depends upon which table(s) or query(ies) you used to design the forms.

If you have other fields on your form already filled in from data input into other forms, then your record source for that form needs to be modified. Are you familiar with the concept of forms and subforms? Typically you would enter only new data into a form to be saved to the table(s). Without additional explanations of how your tables, queries, and forms were designed, it's difficult to give you any concrete answers.

I'd suggest you start first with the examples that come with MS Access. If you don't now where to find them, post back and tell us which version of Access you're using. Additionally, get yourself a good book on Access. Go to any of the online bookstore (Amazon, Barnes& Noble, etc.) and do a search for MS Access boooks. Microsoft publishes many, as do a lot of other great publishing companies. Also do a search on any of the search engines form MS Access Tutorials. There are some basic ones out there:
just a couple of examples. Post back with other questions or comments you have. HTH, Montrose Learn what you can and share what you know.
 
Shalini,
Forgot to say don't just be a visitor here, sign up so you can look at all the Access forums, read the the FAQ, and do searches. You'll learn alot just by reviewing what other folks are doing. HTH, Montrose Learn what you can and share what you know.
 
Dear Montrose,
Thank you very much for your reply.
Let me explain my problem:
I have a main data entry form and there are several command buttons on it.Each button takes to different data entry forms.On my main form I have certain fields(id's like COMPID,MGTID etc).When I enter data on the main form those id's are saved in the table(called COMP).Now when I go to other data entry forms, from which I want to save to the same table COMP,(but other fields), it is saying that duplicate value.(I know why it is doing it since those id's are already entered into the table from my main form).
In the other forms I am retreiving the id's from the main form,so that I can enter other fields related to those id's.
Also those id's are Primary keys.
So now what I am trying to do is, I am going to the other forms from my main form using command buttons.In those forms the id's are already present,but other fields are empty and I am trying to save just the newly entered data and not the data(id's ) retrieved from the main form which are already present.
Hope I have given enough details to figure out the solution.
I appreciate any help.
Also I will take your advice and try to learn more from reading other FAQs,
Thanks again,
Shalini.
 
Shalini,

You're welcome. I'm not an expert with this, but certainly want to share some of the basics I know since others have helped me so much! I see what you're doing & think I understand why. Before you get too far along in this, you need to go back and understand a little more about tables and relationships. Without having details of your table structures, query designs, and subsequent forms, the best I can tell you for now is spend some time reading/surfing/checking out other Access examples. If you get a good basic table design and establish relationships correctly, you'll save yourself from alot of work and frustrations!

It sounds like you should be using a main form and subforms. Subforms RELATE to your main form through the table IDs. Basically, the main form will have a primary key from a table relating to a foreign key in another table, which is used for your subform. Think of the basic family structure. There is a parent(master). A parent can have a child. The child relates to the parent(master). Access actually uses "LinkChildFields" and "LinkMasterFields". Check out Help for that, as well as for all the database objects. Check out tables, you'll see "What they are and how they work". Do the same for queries, forms, subforms, and reports. Read all the screens (they'll have page numbers across the bottom) and click also on the blue words to learn additional information. You'll find info about linking main froms and subforms, you'll learn about which queries you can use as the basis for a form and when you'll be able to add new data to a table through a query based on a form. Access is challenging and fun, but you gotta' get these basics down first! Do a little studying and come back with some more questions when you get stuck. It will also help, as I said in the first response if you give a brief description of your table design and the record source for your forms/subforms. Makes it easier for folks to help if they get closer to what you're actually trying to do. Lots of folks are willing to look at your basic table design (see the MS Access Table Design forum) and suggest changes or improvements.

Don't give up! We all started where you are. Look forward to seeing some more posts from you. Montrose Learn what you can and share what you know.
 
This example allows u to force a new record in a table and add two fields from a form to the table. You of can do more than two if you like just add where necessary.


Private Sub Form_AfterUpdate()
Dim sSQL As String
sSQL = "INSERT Into tablename (tablefield, tablefield2) Values ('" & Me.[formfield] & "', '" & Me.[formfield2] & "')"
DoCmd.RunSQL (sSQL)
End Sub

Hope it helps

Zero
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top