Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

ADODB runtime error

 
   Database Help (Home) -> Visual Basic RSS
Next:  Me vs ADO Data Control.  
Author Message
G. Houston

External


Since: Apr 09, 2004
Posts: 5



(Msg. 1) Posted: Fri Apr 16, 2004 4:02 pm
Post subject: ADODB runtime error
Archived from groups: microsoft>public>vb>database (more info?)

Hello,

I am working with ADODB, and am trying to change the DataSource and
DataField properties of two text boxes on the fly. See article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;189852

I have the following code:

Option Explicit
Dim rsDummy As ADODB.Recordset
Dim rsSales As ADODB.Recordset

Private Sub chkNewSale_Click()

txtNewSaleID.Text = CInt(txtSaleID.Text) + 1

rsSales.AddNew

If txtSaleID.DataField = "Sale#" Then
txtSaleID.DataField = Empty
Set txtSaleID.DataSource = rsDummy
txtSaleID.DataField = "SaleID"
End If

If txtNewSaleID.DataField = "SaleID" Then
txtNewSaleID.DataField = Empty
Set txtNewSaleID.DataSource = rsSales
txtNewSaleID.DataField = "Sale#"
End If

chkNewSale.Enabled = False

End Sub

Private Sub Form_Load()

'initiate recordsets
Set rsDummy = New ADODB.Recordset
Set rsSales = New ADODB.Recordset

rsDummy.Open "Select * from tblDummy",
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Darkstorm
Records.mdb;", adOpenStatic, adLockOptimistic
rsSales.Open "Select * from tblSales",
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Darkstorm
Records.mdb;", adOpenStatic, adLockOptimistic

Set txtSaleID.DataSource = rsSales
txtSaleID.DataField = "Sale#"

Set txtNewSaleID.DataSource = rsDummy
txtNewSaleID.DataField = "SaleID"

Set txtCustID.DataSource = rsSales
txtCustID.DataField = "Customer#"

Set txtStockID.DataSource = rsSales
txtStockID.DataField = "Stock#"

End Sub

-Now, whenever I click on the chkNewSale checkbox, I immediately get the
following error:

"Run-time error '-2147217842 (80040e4e)': Operation was canceled."

Note: the 'rsSales.AddNew' seems to be the eorror-causing code.

Please help!

 >> Stay informed about: ADODB runtime error 
Back to top
Login to vote
Ivan Dormain

External


Since: Jun 15, 2004
Posts: 4



(Msg. 2) Posted: Tue Jun 15, 2004 11:14 am
Post subject: Re: ADODB runtime error [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hey

AddNew prepares for a record entry, you also must use the Update method:

rs.AddNew
rs.fields("fld_lastname").value = "Oscar"
rs.Update

To update a record sipmply use the Update Method without the AddNew.

"G. Houston" wrote in message

> Hello,
>
> I am working with ADODB, and am trying to change the DataSource and
> DataField properties of two text boxes on the fly. See article:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;189852
>
> I have the following code:
>
> Option Explicit
> Dim rsDummy As ADODB.Recordset
> Dim rsSales As ADODB.Recordset
>
> Private Sub chkNewSale_Click()
>
> txtNewSaleID.Text = CInt(txtSaleID.Text) + 1
>
> rsSales.AddNew
>
> If txtSaleID.DataField = "Sale#" Then
> txtSaleID.DataField = Empty
> Set txtSaleID.DataSource = rsDummy
> txtSaleID.DataField = "SaleID"
> End If
>
> If txtNewSaleID.DataField = "SaleID" Then
> txtNewSaleID.DataField = Empty
> Set txtNewSaleID.DataSource = rsSales
> txtNewSaleID.DataField = "Sale#"
> End If
>
> chkNewSale.Enabled = False
>
> End Sub
>
> Private Sub Form_Load()
>
> 'initiate recordsets
> Set rsDummy = New ADODB.Recordset
> Set rsSales = New ADODB.Recordset
>
> rsDummy.Open "Select * from tblDummy",
> "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Darkstorm
> Records.mdb;", adOpenStatic, adLockOptimistic
> rsSales.Open "Select * from tblSales",
> "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Darkstorm
> Records.mdb;", adOpenStatic, adLockOptimistic
>
> Set txtSaleID.DataSource = rsSales
> txtSaleID.DataField = "Sale#"
>
> Set txtNewSaleID.DataSource = rsDummy
> txtNewSaleID.DataField = "SaleID"
>
> Set txtCustID.DataSource = rsSales
> txtCustID.DataField = "Customer#"
>
> Set txtStockID.DataSource = rsSales
> txtStockID.DataField = "Stock#"
>
> End Sub
>
> -Now, whenever I click on the chkNewSale checkbox, I immediately get the
> following error:
>
> "Run-time error '-2147217842 (80040e4e)': Operation was canceled."
>
> Note: the 'rsSales.AddNew' seems to be the eorror-causing code.
>
> Please help!
>
>
>

 >> Stay informed about: ADODB runtime error 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Move to specific row in an ADODB.recordset - Hello! I would like to move to a specific row in a recordset. For example I would like to get the value "MyText" from the 100. row. A very slow approach would be dim l& for l = 1 to rs.recordcount if l = 100 then ... Is there a faster...

data environment in data report- error?Why - I have a vb project and I have used data reports. The reports are working perfectly well here. But when I copy the whole folder to another machine, I cannot open the DataEnvironment and it shows error. Why?All the forms and reports can be opened in..

sql query returns in wrong format - Hi, Hope someone can help me with this. I have MS SQL 2000 database where i have Table "PriceList" and there a column "Pricemk" wich is data type "money". All data in this column is in form "10001,35". So why when...

arrays - is there a way to concatenate the contents of an array (looping through the array) and storing each item in a comma delimited string? Thanks!

DataReport PageBreak - Hi everyone, I would like to know how to force pagebreak in a datareport for example after 5 records printed. Thank you all
   Database Help (Home) -> Visual Basic All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]