OnHand.Edit

 

You cannot do an AddNew without Edit.

 

-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of jsivanan
Sent: Thursday, August 25, 2005 7:54 PM
To: [email protected]
Subject: [Access VBA Central] Object Required. Error 424?

 

Hi,
I haven't used Access Basic for several years, since before DAO and
ADO were needed to be specified. I'm running Access 2000 with ADO 2.1
and ADO 3.6 library references specified. I'm building a little ap to
keep track of inventory for a in-home sales biz and I want to update a
table in the same db but other than the one bound to the form. 

The problem is I get an Object Required error and it halts at
OnHand.AddNew.  

I've read what MSDN says at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr9
8/html/vamsgnotobject.asp

but it doesn't clear it up for me. 
I have tried both a DAO version and an ADO version (see below), but
they both fail the same way.

It didn't complain about the

Dim MyDB As DAO.Database
Set MyDB = CurrentDb
Dim OnHand As DAO.Recordset
Set OnHand = MyDB.OpenRecordset("OnHand")

So I'm assuming it knows the Current DB is open and the OnHand
recordset got opened OK.
Any idea why it's complaining about OnHand.AddNew? 
What object isn't well qualified?

Thanks for your help.

-Jnana
---------------------------------------------
DAO Version
Private Sub Form_AfterInsert()
'Invoke the AddNew method.
    OnHand.AddNew
    OnHand!ItemNo = Me.ItemCombo.Column(1)
    OnHand!Quantity = Me.Quantity
    OnHand.Update

End Sub

Public Sub Form_Load()

Dim MyDB As DAO.Database
Set MyDB = CurrentDb
Dim OnHand As DAO.Recordset
Set OnHand = MyDB.OpenRecordset("OnHand")

End Sub

Private Sub Form_Unload(Cancel As Integer)
OnHand.Close
Set OnHand = Nothing
End Sub

Private Sub ItemCombo_AfterUpdate()
Me.Rate = Me.ItemCombo.Column(2)
Me.Amount = Me.Rate
End Sub

Private Sub Quantity_AfterUpdate()
Me.Amount = Me.Rate
End Sub

Private Sub RateTypeBox_AfterUpdate()
Select Case Me.RateTypeBox
   Case 1
      Me.Rate = Me.ItemCombo.Column(2)
   Case 2
      Me.Rate = Me.ItemCombo.Column(3)
   Case 3
      Me.Rate = Me.ItemCombo.Column(4)
End Select
----------------------------------------
ADO Version

Private Sub Form_AfterInsert()
'Invoke the AddNew method.
    OnHand.AddNew
    OnHand.Fields("ItemNo").Value = Me.ItemCombo.Column(1)
    OnHand.Fields("Quantity") = Me.Quantity
    OnHand.Update

End Sub

Public Sub Form_Load()

Dim oCn As ADODB.Connection
Dim OnHand As ADODB.Recordset
Set oCn = CurrentProject.Connection
Set OnHand = New ADODB.Recordset
OnHand.Open "OnHand", oCn, adOpenKeyset, adLockOptimistic, adCmdTable

End Sub

Private Sub Form_Unload(Cancel As Integer)
OnHand.Close
oCn.Close
Set OnHand = Nothing
Set oCn = Nothing
End Sub

Private Sub ItemCombo_AfterUpdate()
Me.Rate = Me.ItemCombo.Column(2)
Me.Amount = Me.Rate
End Sub

Private Sub Quantity_AfterUpdate()
Me.Amount = Me.Rate
End Sub

Private Sub RateTypeBox_AfterUpdate()
Select Case Me.RateTypeBox
   Case 1
      Me.Rate = Me.ItemCombo.Column(2)
   Case 2
      Me.Rate = Me.ItemCombo.Column(3)
   Case 3
      Me.Rate = Me.ItemCombo.Column(4)
End Select

Me.Amount = Me.Quantity * Me.Rate
End Sub









SPONSORED LINKS 

Microsoft access database
<http://groups.yahoo.com/gads?t=ms&k=Microsoft+access+database&w1=Micros
oft+access+database&w2=Microsoft+access&w3=Microsoft+access+database+des
ign&w4=Microsoft+access+database+training&c=4&s=131&.sig=_NMBmgHqxR8S8tj
yGl-Tnw>  

Microsoft access
<http://groups.yahoo.com/gads?t=ms&k=Microsoft+access&w1=Microsoft+acces
s+database&w2=Microsoft+access&w3=Microsoft+access+database+design&w4=Mi
crosoft+access+database+training&c=4&s=131&.sig=-5Xf2KTU4AmC58h30Cq3wg>


Microsoft access database design
<http://groups.yahoo.com/gads?t=ms&k=Microsoft+access+database+design&w1
=Microsoft+access+database&w2=Microsoft+access&w3=Microsoft+access+datab
ase+design&w4=Microsoft+access+database+training&c=4&s=131&.sig=rEvcpxWQ
YfjON1btwfI3Aw>  

Microsoft access database training
<http://groups.yahoo.com/gads?t=ms&k=Microsoft+access+database+training&;
w1=Microsoft+access+database&w2=Microsoft+access&w3=Microsoft+access+dat
abase+design&w4=Microsoft+access+database+training&c=4&s=131&.sig=pILo23
-rKYDuxPwf_IbrRQ>  

 

 

 

  _____  

YAHOO! GROUPS LINKS 

 

*          Visit your group "AccessVBACentral
<http://groups.yahoo.com/group/AccessVBACentral> " on the web.
  

*          To unsubscribe from this group, send an email to:
 [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]
> 
  

*          Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> . 

 

  _____  



This email and any attachments contain information from Baker & Taylor which 
may 
be confidential, privileged and/or protected by other legal rules. If you are 
not the
intended recipient, you are hereby advised that any disclosure, copying, 
distribution or
use of the contents of this email is prohibited. If you have received the email 
in error, 
please notify us by reply email immediately and then delete the email and your 
reply
from your email system. NOTE: Baker & Taylor accepts no liability for the 
contents of 
this email. This email shall not operate to bind Baker & Taylor to any 
contract, order 
or other obligation. 


[Non-text portions of this message have been removed]





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/q7folB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AccessVBACentral/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to