New User: Adding records to a database 
Author Message
 New User: Adding records to a database

I have made a program which displays data from a database on one form
and another form that allows the user to add to my database.  I am
using Visual Basic 3.0 Standard, and I am using an Access 2.0
database.

I got the program to display the data, but I do not know how to allow
the user to add to the database.

The form that will allow the user to add records has the following:

2 text boxe( to input data),  a data control called data1(connected to
my database), and a command button that exits the screen and that I
want to update the database.

I am working with two different tables in my database called male and
female

I used the following code:

data1.recordsource = "Female"
data1.refresh
data1.recordset.addnew
data1.recordset.fields("name") = name.text
data1.recordset.fields("town") = town.text
data1.recordset.update

I know the code is probably totaly wrong so I would really be grateful
if anyone can tell me the proper code to use.


Thanks :)



Mon, 18 May 1998 03:00:00 GMT  
 New User: Adding records to a database

Quote:
> I have made a program which displays data from a database on one form
> and another form that allows the user to add to my database.  I am
> using Visual Basic 3.0 Standard, and I am using an Access 2.0
> database.

> I got the program to display the data, but I do not know how to allow
> the user to add to the database.

The easiest way to do this is to display the second form as a modal form.
This way it will only ever be displayed as the result of code running
on the first form, so you can be sure that whenever the second form is
up the first is to. You can then access the data control on the first form

Form1.Data1.Recordset.AddNew
Form1.Data1.Recordset!Field1 = text1.text
Form1.Data1.Recordset!Field2 = text2.text
Form1.Data1.Recordset.Update

Add a little global variable to your form to indicate whether the user wants
to add or edit data and your second form can double up as both an amendment
and data entry form.

If you still get stuck, let me know and I will send you some sample code.

Peter

--
+--------------------------------------------------------------------+
|               PSYNET LTD => HOME OF THE INTERNET HAMSTER           |
|           PROVIDING BUSINESS WITH SOLUTIONS NOT PROBLEMS           |
+--------------------------------------------------------------------+
|  E-MAIL                          |  Psynet Ltd                     |



|                                  |  BN22 9RG   (UK) 1323 507664    |
+----------------------------------+---------------------------------+

PGP PUBLIC KEY FOLLOWS

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6

mQCNAjBxZt0AAAEEANz14+MdmCoYYLaxnfl3gRATe7VuOxLefkBXmHhHM9cTWhro
dH5yW9LdzkHHdqarid+ZdFdLoWWqxTqCvGOIgCY79YvEGkoaXa8qiCdqJWQpCnHi
vXJ/4ye9krXjUNdYs3WyZo4lGlnI7Ck706UosXMZpb81WOTpAP4lvs/575fVAAUR
tCdQZXRlciBXcmlnaHQgPHBldGVyQGdlbmRldi5kZW1vbi5jby51az4=
=KjmD
-----END PGP PUBLIC KEY BLOCK-----



Tue, 19 May 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to add new records in a new database

2. adding new records & new record

3. Multi-user: clientA can't see new records added by clientB

4. Weird ASP error when trying to add a new record to a MS Access database

5. Problem adding new record to SQL database recordset

6. adding records to new database - cancelled by associated object

7. Can't add new record to Access database with DataControl

8. Remote Data Control--Problems with Adding new Record to SQL Server 6.0 Database

9. add new record to MS ACCESS database

10. Can't add new record to Access database with data control

11. HELP!! DBCombo Box , adding new records in database

12. Trying to add new record to Access database

 

 
Powered by phpBB® Forum Software