Link to home
Start Free TrialLog in
Avatar of Warsteiner99
Warsteiner99

asked on

Saving to a database

what is the code that could be used that when a button is pressed takes information in text3.text and text4.text and saves it into a database, witht txt3.text going into the "surname" field, and text4.text going into the "number" field.
ASKER CERTIFIED SOLUTION
Avatar of esolve
esolve
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AdamB_Open
AdamB_Open

private sub button_click()
Dim dbs as database
dim rst as recordset

set dbs=opendatabase(filename)
set rst=dbs.openRecordset("Select * From Tablename")
rst.edit
rst.add
rst.fields("surname")=text3'.text
rst.fields("number")=text4'.text
rst.update

'If you wish to save as a new record.
'filename is the *.mdb name and path
'Tablename is the name of the table where the fields surname and number are found
'If you wish to save the data in an existing record you will need some more code.