VB6 ADO Access97 and data environments 
Author Message
 VB6 ADO Access97 and data environments

I'm having some problems with an app I'm playing around with while
learning VB.

I thought that if I used a data environment I'd be able to share data
accross the forms better, and this works really well.  But how do you
add new records?

I have an Access table with VidID, VideoTitle, and DatePurchased in it
and I want to add another from a VB Form.  There is also a auto-inc
field as the first column in the table called ID.

In the data environment, I have a connection which is linked to my DSN
source VideoDB, which I set up in ODBC (32 bit) in the control panel.
Next I set up a command as an object under my connection.  I changed
it to a table type command with the table AllVideos.  But if I do an
dataenvironment1.rscommand1.addnew I get an error saying 'invalid or
unreferenced qualifier.'  Now, I'm not sure I'm doing this entirely
right...but I am going by example code in the docs.  here's what I
have...

Private Sub cmdAddNewVideo_Click()
  envVideoConnection.rsVideoTable.AddNew
    !VidID = txtVidID.Text
    !VideoTitle = txtVideoTitle.Text
    !DatePurchased = txtDatePurchased.Text
End Sub

Should I be putting something in for the auto-inc field?  What causes
this error to pop up?  Am I calling AddNew wrong?

Thanks for any help.

<ChipOne>



Mon, 21 May 2001 03:00:00 GMT  
 VB6 ADO Access97 and data environments
James,

Make sure that the LockType property of the command is not
adLockReadOnly.  Also put the Update method after you set the values in
order to save your data.
    Private Sub cmdAddNewVideo_Click()
        With envVideoConnection.rsVideoTable
            .AddNew
            !VidID = txtVidID.Text
            !VideoTitle = txtVideoTitle.Text
            !DatePurchased = txtDatePurchased.Text
            .Update
        End With
    End Sub

If this still doesn't work, put # signs on either side of the date
    !DatePurchased = "#" & txtDatePurchased.Text & "#"

Matt Ridge

Quote:

> I'm having some problems with an app I'm playing around with while
> learning VB.

> I thought that if I used a data environment I'd be able to share data
> accross the forms better, and this works really well.  But how do you
> add new records?

> I have an Access table with VidID, VideoTitle, and DatePurchased in it
> and I want to add another from a VB Form.  There is also a auto-inc
> field as the first column in the table called ID.

> In the data environment, I have a connection which is linked to my DSN
> source VideoDB, which I set up in ODBC (32 bit) in the control panel.
> Next I set up a command as an object under my connection.  I changed
> it to a table type command with the table AllVideos.  But if I do an
> dataenvironment1.rscommand1.addnew I get an error saying 'invalid or
> unreferenced qualifier.'  Now, I'm not sure I'm doing this entirely
> right...but I am going by example code in the docs.  here's what I
> have...

> Private Sub cmdAddNewVideo_Click()
>   envVideoConnection.rsVideoTable.AddNew
>     !VidID = txtVidID.Text
>     !VideoTitle = txtVideoTitle.Text
>     !DatePurchased = txtDatePurchased.Text
> End Sub

> Should I be putting something in for the auto-inc field?  What causes
> this error to pop up?  Am I calling AddNew wrong?

> Thanks for any help.

> <ChipOne>



Fri, 25 May 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ADO and the Data Environment (VB6 EE)

2. VB6 ADO Data Environment Bug or not

3. VB6 ADO application can't show data in runtime environment

4. VB6 ADO Access 97 and Data Environments

5. Data Environment and Access97 DB with Password HELPPPPP

6. use ado control, ado object or data environment?

7. VB6 Data Environment & Data Report

8. closing ADO data controls and data environment connections

9. ado data control vs. data environment

10. Problems with ADO data control and data environment

11. Data Environment or ADO Data Control?

12. Data Environment or ADO Data Control?

 

 
Powered by phpBB® Forum Software