HOW TO SAVE DATA IN ACCESS & ORACLE TABLE FROM VISUAL BASIC FORM

M

Mohsin

Good Morning to All (Christmas Greetings),

indeed many thanks for your prompt response apropos my question.

as every body knows that visual basic is Application Bulider.

suppose, i am going to make a simple programme for two Numbers
Calculation. i designed a Form in visual basic to enter the data .

1st text box is Enter the 1st number. ( textbox name is T1)
2nd text box is Enter the 2nd number.( textbox name is T2)
3rd text box is total.( textbox name is T3)

made two buttons which are SAVE & EXIT (name is save and EXIT)

if i will enter data in textbox T1 & T2 and click on SAVE button then
it will make calculation of two numbers whatever user will enter in
aforesaid textbox and should be save in Access table.

To save the data in Access table i have to make a table in access ,
isn't it.

i made one table in access with the name of calculation and data field
is First_Number, Second_Number and Total and saved this access file in
my document Folder.

first of all to make a link between access table and visual basic form
what will i do,

i think i have to make link through data control and ODBC. is it right.


but when i make a link thourgh this. it shows errors hence please let
me know the full procedure how will i make link access table with VB
form both way and what will i write on SAVE button to save this data in

Access Table.

on Private Sub cmdSave_Click()
T3.text=val(T1.text)+val(T2.text)--to Calculate the data
ConnectionObject.Recordset.Update - to save the data
End Sub

i do hope that my query is obvios now and every body can realize that
what am i facing problem to this data in access Table.

your cooperation on this regard will be highly appreciated.

Regards
Mohsin
 
M

Marshall Barton

Mohsin said:
as every body knows that visual basic is Application Bulider.

suppose, i am going to make a simple programme for two Numbers
Calculation. i designed a Form in visual basic to enter the data .

1st text box is Enter the 1st number. ( textbox name is T1)
2nd text box is Enter the 2nd number.( textbox name is T2)
3rd text box is total.( textbox name is T3)

made two buttons which are SAVE & EXIT (name is save and EXIT)

if i will enter data in textbox T1 & T2 and click on SAVE button then
it will make calculation of two numbers whatever user will enter in
aforesaid textbox and should be save in Access table.

To save the data in Access table i have to make a table in access ,
isn't it.

i made one table in access with the name of calculation and data field
is First_Number, Second_Number and Total and saved this access file in
my document Folder.

first of all to make a link between access table and visual basic form
what will i do,

i think i have to make link through data control and ODBC. is it right.


but when i make a link thourgh this. it shows errors hence please let
me know the full procedure how will i make link access table with VB
form both way and what will i write on SAVE button to save this data in

Access Table.

on Private Sub cmdSave_Click()
T3.text=val(T1.text)+val(T2.text)--to Calculate the data
ConnectionObject.Recordset.Update - to save the data
End Sub

i do hope that my query is obvios now and every body can realize that
what am i facing problem to this data in access Table.


What you are facing is painfully obvious, but it is not the
problem of how to save a calculated value. The problem is
that you are thinking spreadsheet when you need to think
relational database.

One of the fundamental rules of relational database tables
(not just Access) is that you should **never** save a value
in a table that can be calculated from other saved values.
Instead, you should recalculate the value whenever you need
to display it (or use it in another calculation).

From what you've explained so far, I suggest that you get
rid of the T3 field in the table and use a query that has a
calculated field to display the total:
SELECT T1, T2, T1 + T2 As T3 FROM the table

I also think you are overly restricting your options when
you say VB is the application builder. For database
applications, Access is far more focused and it provides
many, many data centric features that make creating a
database related application a whole lot easier than using a
general prurpose tool like VB.

To try to answer the question you asked, you could use DAO
(or ADO) to open a recordset and assign the total to to the
appropriate record. You may need to read a few chapters in
an appropriate book to learn what recordsets are all about.
However, even after doing all that, there is a good chance
that you can change a value in T1 or T2 and fail to update
T3, at which point the data in the table will be
inconsistent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top