I am new bee in programming. i have created a Small program in VB & I want 2 save it in MS Access 2007. getting problem which is not recognized by me where i am doing wrong.
Hence i have attached my programme as project1.zip Pl tell me where giving wrong.
Thanks
|
Go4Expert Founder
|
![]() |
| 7Mar2010,18:24 | #2 |
|
Please do not attach your code and ask to get it answered. I doubt you will do the same for others.
Explain what is not working and we would be more than happy to answer.
viv345
like this
|
|
Pro contributor
|
![]() |
| 8Mar2010,02:04 | #3 |
|
try the changes below
Code:
Option Explicit
Dim conn As New ADODB.Connection
Dim cmdCommand As New ADODB.Command
Dim rec As New ADODB.Recordset
Private Function connect()
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\" & "db1.mdb;Mode=Read|Write"
conn.CursorLocation = adUseClient
conn.Open
cmdCommand.ActiveConnection = conn
cmdCommand.CommandType = adCmdText
rec.CursorType = adOpenDynamic
rec.CursorLocation = adUseClient
rec.LockType = adLockOptimistic
End Function
Private Sub Form_Load()
connect
End Sub
Private Sub Command1_Click()
cmdCommand.CommandText = "SELECT * FROM table1;"
rec.Open cmdCommand
rec.AddNew
rec.Fields(1) = Text1.Text
rec.Fields(2) = Text2.Text
rec.Fields(3) = Text3.Text
rec.Fields(4) = Text4.Text
rec.Update
'If Not rec.EOF Then rec.MoveNext
MsgBox "record stored"
rec.Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
conn.Close
End Sub
Private Sub Text2_Click()
Form1.Text2.Text = Val(Form1.Text1.Text) * 1#
End Sub
Private Sub Text3_Click()
Form1.Text3.Text = Val(Form1.Text1.Text)
End Sub
Private Sub Text4_Click()
Form1.Text4.Text = Val(Form1.Text2.Text)
End Sub
viv345
like this
|
|
Contributor
|
|
| 11Mar2010,18:41 | #4 |
|
In my previous Project i have add some new commands like Next; Previous and Delete.
How I can code to move around my saved data. |
|
Contributor
|
|
| 11Mar2010,18:43 | #5 |
|
In my previous Project i have add some new commands like Next; Previous and Delete.
How I can code to move around my saved data. i am getting problem. When click on next, Highlights Private Sub Command2_Click () and on End Sub, is this wrong. Pl Help |
|
Contributor
|
|
| 14Mar2010,11:56 | #6 |
|
THANKS
Can data saved in access remain constant after quitting the programme. and if delete/clear button is clicked how i can delete data in access |
|
Pro contributor
|
![]() |
| 15Mar2010,13:59 | #7 |
|
i have made some changes in your code.
1) code for deleting records (delete button) 2) code for next,previous (considering error situations,with appropriate messages) 3) button NEW added (press this to empty text boxes,add data and press save to store in DB) 4) label showing current record out of how many records and many more. check the code. for more questions post again.
viv345
like this
|
|
Contributor
|
|
| 16Mar2010,16:25 | #8 |
|
Thanks
|
|
Contributor
|
|
| 16Mar2010,18:14 | #9 |
|
I want know one more thing that if their are more forms in a project viz., Form 1, Form2 etc etc then what will be the coding.
AND In this project on this command it is giving error Run-time error '3704' Operation is not allowed when the object is closed Private Sub Command8_Click() 'save button rec.AddNew rec.Fields(1) = Text1.Text rec.Fields(2) = Text2.Text rec.Fields(3) = Text3.Text rec.Fields(4) = Text12.Text rec.Fields(5) = Text13.Text rec.Update MsgBox "record stored" currentRecord = currentRecord + 1 Label3.Caption = "Record " + CStr(currentRecord) + " of " + CStr(rec.RecordCount) End Sub |




button instead.