Update does not stick, AddNew won't add 
Author Message
 Update does not stick, AddNew won't add

VB6 SP5 Access 2000 On a form when I change a record, the change shows up.
When I leave the program and come back, the change is gone, and the original
data is back.
Text boxes are bound to DB. I make the changes and click a command button
with code
"Adodc1.Recordset.Update"

"Adodc1.Recordset.Delete" works fine.

"Adodc1.Recordset.AddNew" creates an error, here is the code:

Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum,
ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal
pRecordset As ADODB.Recordset)
With Adodc1.Recordset
       If .EOF Or .BOF Then
           Text2.Text = ""
       Else
 ====> Text2.Text = .Fields("REF").Value <====
       End If
   End With

End Sub
====> This is what is highlighted on error <====

Run Time error 94
Invalid use of null
Help



Thu, 24 Feb 2005 20:08:44 GMT  
 Update does not stick, AddNew won't add
When you are adding a new record you are trying to place a non existent value
(null) into a text box. You can't set a property to something that does not
exist.

If you are trying to place some previous ID value into a new record, then you
need to pass the value to a variable before the addnew is called. Then after the
addnew, pass the value of the variable into the field of the new record.
Cheers
Dave


Quote:
> VB6 SP5 Access 2000 On a form when I change a record, the change shows up.
> When I leave the program and come back, the change is gone, and the original
> data is back.
> Text boxes are bound to DB. I make the changes and click a command button
> with code
> "Adodc1.Recordset.Update"

> "Adodc1.Recordset.Delete" works fine.

> "Adodc1.Recordset.AddNew" creates an error, here is the code:

> Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum,
> ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal
> pRecordset As ADODB.Recordset)
> With Adodc1.Recordset
>        If .EOF Or .BOF Then
>            Text2.Text = ""
>        Else
>  ====> Text2.Text = .Fields("REF").Value <====
>        End If
>    End With

> End Sub
> ====> This is what is highlighted on error <====

> Run Time error 94
> Invalid use of null
> Help



Fri, 25 Feb 2005 04:07:53 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. not to auto update while doing addnew

2. dbCombo - Stick a fork in it, it's done

3. dbCombo - Stick a fork in it, it's done

4. report won't stick

5. Form resizing won't stick

6. Why won't printer settings stick?

7. DataBound PictureBox won't stick

8. AddNew just won't happen

9. Porting AC'97 .addnew and .update for compatibility w/SQL 7

10. Counter Fields - value assigned on Addnew not Update?

11. Can't AddNew/Update with ADO Data Control

12. Addnew and update method in ADOCE not working ?

 

 
Powered by phpBB® Forum Software