ADDNEW Method Problem

Reply

Join Date: Nov 2008
Posts: 1
Reputation: saurabh.punn is an unknown quantity at this point 
Solved Threads: 0
saurabh.punn saurabh.punn is offline Offline
Newbie Poster

ADDNEW Method Problem

 
0
  #1
Nov 13th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 62
Reputation: Baradaran is an unknown quantity at this point 
Solved Threads: 4
Baradaran Baradaran is offline Offline
Junior Poster in Training

Re: ADDNEW Method Problem

 
0
  #2
Nov 13th, 2008
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
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. rs.open "Select * From your_table;", conn, 3, 3
  3. with rs
  4. .AddNew
  5. !Username = text1.text
  6. !Password = text2.text
  7. .Update
  8. End With

This should work.

Good luck!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC