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.

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Baradaran
0

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

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!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.