Object Doesn't Support This Property Or Method??

CosmicKid

Registered User.
Local time
Today, 16:56
Joined
Dec 5, 2008
Messages
11
Hi All,

I'm sure this issue has come up elsewhere on the forum, but I can't find a solution...any help would be most appreciated.

Overview is this - I have a form showing records of company info and a subform where the user can enter an account number associated with that company.
The main form "frmCompanyEntry" has a button "AddNewAccount" that on the button's "On Click" event -
1. makes visible the subform "subfrmAccountAdd1"
2. starts a new record in the underlying table "tblAccounts"
3. sets the CompanyID field of "tblAccounts" to match the CompanyID field of the current record on the parent form from the table "tblCompany"
4. moves the focus to the AccountNumber field (the only visible field on the subform)
There is a button next to the AccountNumber field to save the record, move the focus off the subform and set the form as not visible.

OK - so everything seems to be working, but when the main form's "AddNewAccount" button is "clicked", I get a warning saying "doesn't support this property or method". I can click it away and the subform works fine, but I can't get rid of the warning.....
here is the code in the main form:
Code:
Private Sub AddNewAccount_Click()
On Error GoTo Err_AddNewAccount_Click
    Dim stDocName As String
    Dim AddCompID As Integer
 
    AddCompID = Me![CompanyID]
    stDocName = "subfrmAccountAdd1"
    Forms!frmCompanyEntry!subfrmAccountAdd1.Visible = True
    Me.subfrmAccountAdd1.SetFocus
    DoCmd.GoToRecord , , acNewRec
    Me.subfrmAccountAdd1.[CompanyID] = AddCompID
    Me.subfrmAccountAdd1.[AccountNumber].SetFocus
Exit_AddNewAccount_Click:
    Exit Sub
Err_AddNewAccount_Click:
    MsgBox Err.Description
    Resume Exit_AddNewAccount_Click
 
End Sub

and here is the only code in the subform (to save record, move focus and set visibility to false
Code:
Private Sub SaveNewAccount_Click()
On Error GoTo Err_SaveNewAccount_Click
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    Forms!frmCompanyEntry!subfrmAccounts.Form.Requery
    Forms!frmCompanyEntry!CoName.SetFocus
    Forms!frmCompanyEntry!subfrmAccountAdd1.Visible = False
Exit_SaveNewAccount_Click:
    Exit Sub
Err_SaveNewAccount_Click:
    MsgBox Err.Description
    Resume Exit_SaveNewAccount_Click
 
End Sub

I am very much a beginner at access so any advice would be helpful

Thanks in advance.
 
Best way to tackle this problem is to comment out all of the lines of code and then add them back in until you see the error message reappear.

To comment out a line of code you put an apostrophe in front of the line for example :

Forms!frmCompanyEntry!subfrmAccountAdd1.Visible = True

'Forms!frmCompanyEntry!subfrmAccountAdd1.Visible = True
 
Best way to tackle this problem is to comment out all of the lines of code and then add them back in until you see the error message reappear.

Thanks for the tip, Gizmo.

As I suspected, the offending code is:

Me.subfrmAccountAdd1.[CompanyID] = AddCompID

but sadly, I'm still stumped. I've set AddCompID as an integer and both CompanyID fields in the two tables are set to long integer...I must be missing something.
 
I believe it's a syntax problem:

http://www.mvps.org/access/forms/frm0031.htm

FWIW, my thought on the easiest way to find it would simply be to comment out the

On Error GoTo...

line and run the code again. Without the error handler, you should be given the "Debug" option and be taken straight to the offending line.
 
Syntax problem it was:

Me.subfrmAccountAdd1.[CompanyID] = AddCompID
Me.subfrmAccountAdd1.[AccountNumber].SetFocus

replaced with:

Me.subfrmAccountAdd1.Form!CompanyID = AddCompID
Me.subfrmAccountAdd1.Form!AccountNumber.SetFocus


Thanks all!
 

Users who are viewing this thread

Back
Top Bottom