Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 insert data into SQL server from Access Form

Author  Topic 

sneha24
Starting Member

4 Posts

Posted - 2011-02-04 : 23:51:55
Hi All,

I am new to Access and VB programming.
I am using SQL server as the backend database and access form is the front end tool where i need to enter the information and the data must be directly inserted into transaction table in SQL Server.

I have created ODBC Connection which is working fine. I have also created linked tables to the data sources. I am able to see the SQL Server data from access.

Issue:
The transactional table has transaction id which should be an autogenerated sequence number and also the primary key, customer id, customer name, customer product.

I have created a form on Transaction table. I have transaction_id as invisible column, customer id, customer name and product as the visible columns on the form fmTransaction.
when i fill customer id number , custimenr name should be auto filled.

I found this code in a website and will be using this to autofill customer info.
Private Sub Customerid_GotFocus ()
If IsNull (Me!Customerid) Then
Me! [Customerid]. Dropdown
End If
End Sub

Not sure if it works!

I need help to auto generate the transaction id sequence and i also need the program to save the transaction into the transaction table in SQL Server.

Any help is greatly appriciated.

Thanks
Sneha

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2011-02-07 : 05:29:34
If you have bound the form to the table, add a save button with Me.Save as your code. If it is unbound, then it will take a lot more code to save it, you would need to open a recordset and set all the fields. If transaction_id is auto generated, you do not need to worry about it as it will be generated by SQL when you save the rest of the data (although you may want to retrieve the number at a later point, in which case you need a way of getting the number).
Go to Top of Page
   

- Advertisement -