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:
and here is the only code in the subform (to save record, move focus and set visibility to false
I am very much a beginner at access so any advice would be helpful
Thanks in advance.
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.