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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving data from form to table

Status
Not open for further replies.

Dina01

Programmer
Mar 26, 2002
204
CA
I have a form that contains a few combo box, and I would like to create a save button, that will save the data into a table. But all my table are independant and I don't have any relationship between the table to be able to link them together.

How do I choose the data from the independant combo box and save them to a table.

Can someone please tell me or show me an example.

Thanks
 
Let's assume your COMBO1 has data in it that represents an employee name. After you've selected an employee name, you want to post that to an employees table.

Sub Combo1_After_Update()
dim empRst as recordset

set empRST = CurrentDB.OpenRecordset("tblEMployees")

with rst
.addnew
.Empname = me!combo1
.update
.close
end with

Set RST = Nothing

end sub
---------------------------------------
As you can see, you use recordsets to open target tables and then assign unbound data to fields in the target table. Just expand on this example for your particular purposes.

HTH

Jim

78.5% of all statistics are made up on the spot.
Another free Access forum:
More Access stuff at
 
I tried to do this but I keep on getting a compiler error and when I try to debug it stops at .categorie

This is my code

******************************
Private Sub Btn_OK_Click()
Dim rs As Recordset

Set rs = CurrentDb.OpenRecordset("Urg_MedicaleDescrip")

With rs
.AddNew
.Categorie = Me!Categorie
.Priorite = Me!Priorite
.descriptions = Me!description
.Lieux = Me!Lieux
.Niveau = Me!Niveau
.Emplacement = Me!Emplacement
.precision = Me!précisions
.Telephone = Me!Telephone
.NumEmployé = Me!NoEmpl
.nomfamille = Me!DemandeurNom
.commentaires = Me!commentaires
.sexe = Me!sexe
.age = Me!age
.consciencedescription = Me!EtatCons
.respiration = Me!respiratoire
.pouls = Me!pouls
.Informations = Me!Informations
.Agt1 = Me!Agt1
.Agt2 = Me!Agt2
.Agt3 = Me!Agt3
.Agt4 = Me!Agt4
.Agt5 = Me!Agt5
.Agt6 = Me!Agt6
.Agt7 = Me!Agt7
.Ambu = Me!Ambu
.patrouille = Me!patrouille
.HrsSupSecAvise = Me!HrsSupSecAvise
.HrsSurvAvise = Me!HrsSurvAvise
.HrsEntMenAvise = Me!HrsEntMenAvise
.HrsAviseInfirm = Me!HrsAviseInfirm
.HrsClientDirect = Me!HrsClientDirect
.HrsRendrePlace = Me!HrsRendrePlace
.HrsRegul = Me!HrsRegul
.HrsUrgSante = Me!HrsUrgSante
.HrsPolice = Me!HrsPolice
.HrsPompier = Me!HrsPompier
.HrsRecu = Me!HrsRecu
.HrsDebut = Me!HrsDebut
.HrsFin = Me!HrsFin
.IncidentIdicatif = Me!IncidentIdicatif
.IncidentSeq = Me!IncidentSeq
.hospitalierdescription = Me!CentreHosp

.Update
.Close
End With


My table is called "Urg_MedicaleDescrip" and it included all the fields listed above, except for my MedicaleDescripID which is an autonumber..
 
Try changing your DOT.fieldname to BANG!fieldname. Access can get persnickity sometimes when it comes to bangs vs dots. The usual rule I follow is BANG before a fieldname and DOT before a method or property

.ADDnew <--- because it is a method
.Visible = false <--- because it is a property
!Categorie <-- because it is a field name



There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top