Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Doesn't recognize form object - MS Access 2000

Status
Not open for further replies.

relewis

Programmer
Apr 30, 2001
12
US
I've written the code below to be activated when a command button is clicked on a form:

Private Sub Command0_Click()

Dim rst As Recordset
Dim formholder As Variant
Dim multi As Long

Set formholder = Form![frmaccrual_vendor_invoice]

Set rst = formholder.RecordsetClone

multi = Form![frmaccrual_vendor_invoice]![StateTax] + Form![frmaccrual_vendor_invoice]![CityTax] + _
Form![frmaccrual_vendor_invoice]![MTA Tax] + Form![frmaccrual_vendor_invoice]![StateTax]

rst.MoveFirst

While Not rst.EOF

Form![frmaccrual_vendor_invoice]![StateTax] = Me![Text1]
Form![frmaccrual_vendor_invoice]![CityTax] = Me![Text2]
Form![frmaccrual_vendor_invoice]![MTATax] = Me![Text4]
Form![frmaccrual_vendor_invoice]![StateTax] = Me![Text6]

Form![frmaccrual_vendor_invoice]![TaxAmt] = multi * Form![frmaccrual_vendor_invoice]![TaxableAmt]

rst.MoveNext

Wend

End Sub

Execution stops at the 5th line of code and I get the message "MS Access cannot find the field 'frmaccrual_vendor_invoice'. "frmaccrual_vendor_invoice" is not a field but a form.

I can't figure out what I'm doing wrong. Can someone help?

Robin
 
Hi,

this is obviously done in the module behind the form, don’t use the form name but the Me.FielName notation.



Jean-Paul
Montreal
To send me E-Mail, remove “USELESSCODE”.
jp@USELESSCODEsolutionsvba.com
 
Hi relewis,

The problem is that you have Form instead of Forms. Access is confused as to which Form you are referring to and doesn't know you are referring to the Forms Collection so doesn't recognise [frmaccrual_vendor_invoice] as a Form.

Enjoy,
Tony
 
Tony,

You are so right. I figured that out just before I clicked the e-mail that told me about your reply.

I"m so embarrassed. Thanks for the help, however.

Robin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top