| | |
ADDNEW Method Problem
![]() |
•
•
Join Date: Nov 2008
Posts: 1
Reputation:
Solved Threads: 0
Hi All
I am using MS ACCESS 2003 and VB version 6.0.I made a Blank database in ACCESS with a table having fields Username & Password.
My VB application consists of 2 textboxes and a command button.
I established the connection using "Microsoft.Jet.OLEDB.4.0"(coz i tried first 3.51 but it wasnt working).
In the RECORDSOURCE Tab , I specified the CommandType as "adcmdTable" and selected my fresh table(Having no data).
For filling my fresh table:
I tried the following code in the Command1_Click()
Private Sub Command1_Click()
With Adodc1.Recordset
.AddNew
.Fields(0) = Text1.Text
.Fields(1) = Text2.Text
.Update
End With
End Sub
Even I tried
Just to verify)
Private Sub Command1_Click()
With Adodc1.Recordset
.AddNew
.Fields("Username") = Text1.Text
.Fields("Password") = Text2.Text
.Update
End With
End Sub
I am getting the following error:
Run time error-91: Object variable or with block not set..
I tried every approach I was able to find but no use.
Please help me out.
I am using MS ACCESS 2003 and VB version 6.0.I made a Blank database in ACCESS with a table having fields Username & Password.
My VB application consists of 2 textboxes and a command button.
I established the connection using "Microsoft.Jet.OLEDB.4.0"(coz i tried first 3.51 but it wasnt working).
In the RECORDSOURCE Tab , I specified the CommandType as "adcmdTable" and selected my fresh table(Having no data).
For filling my fresh table:
I tried the following code in the Command1_Click()
Private Sub Command1_Click()
With Adodc1.Recordset
.AddNew
.Fields(0) = Text1.Text
.Fields(1) = Text2.Text
.Update
End With
End Sub
Even I tried
Just to verify)Private Sub Command1_Click()
With Adodc1.Recordset
.AddNew
.Fields("Username") = Text1.Text
.Fields("Password") = Text2.Text
.Update
End With
End Sub
I am getting the following error:
Run time error-91: Object variable or with block not set..
I tried every approach I was able to find but no use.
Please help me out.
•
•
Join Date: Feb 2007
Posts: 62
Reputation:
Solved Threads: 4
Hi,
this does not seem to be complicated. Please change the command click sub as follows. Please dim both the recordset and the connection before running the code.
Imagine: conn = the connection, and rs = the recordset
This should work.
Good luck!
this does not seem to be complicated. Please change the command click sub as follows. Please dim both the recordset and the connection before running the code.
Imagine: conn = the connection, and rs = the recordset
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
rs.open "Select * From your_table;", conn, 3, 3 with rs .AddNew !Username = text1.text !Password = text2.text .Update End With
This should work.
Good luck!
![]() |
Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Using database tools inside VB6
- Next Thread: error msg when try to install vb6 runtime
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic beginner birth bmp calculator cd cells.find click client code college connection connectionproblemusingvb6usingoledb creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web windows





