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/vbenlr98/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 ------------------------ Yahoo! Groups Sponsor --------------------~--> Fair play? Video games influencing politics. Click and talk back! http://us.click.yahoo.com/T8sf5C/tzNLAA/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/
