Setting Controls Via Code

B

boborta

I have a parent form has a 'Reset' button, which sets data values (as
defined by value in Tag property) to "" by calling a function.
The function requires one argument: a form name. The function works
correctly on the parent form, but not the child form.
"Error 2467: Application-defined or object-defined error".



Access 2000

Unbound parent form with an unbound child form.


I have tried setting the subform's variable two ways, neither works:
Set frm2 = Form![sfrmEdits]
Set frm2 = Forms![frmAuditDataEntry]![sfrmEdits].Form

Here is the on_click event of the reset button:

Private Sub btnReset_Click()
'-------------------------------------------------------------
' Purpose :
' Author :
' Phone:
' E-Mail:
' Calls:
'-------------------------------------------------------------
' Revision History
'-------------------------------------------------------------
' Saturday, February 07, 2004 RGO:
'=============================================================
' End Code Header block
Dim frm As Form
Dim frm2 As Form
On Error GoTo HandleErr
Set frm = Forms![frmAuditDataEntry]
'Set frm2 = Form![sfrmEdits]
Set frm2 = Forms![frmAuditDataEntry]![sfrmEdits].Form
Call ResetControls(frm)
Call ResetControls(frm2)


ExitHere:
Exit Sub
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description,
vbCritical, "Form_frmA03.btnReset_Click"

End Select
End Sub

Here is the reset function code:

Public Function ResetControls(frm As Form)
' Resets controls if their Tag value is: Comment, D, C, or E .
Dim crl As Control
With frm
For Each crl In frm

If crl.Tag = "Comment" Then
'MsgBox "Name " & crl.Name, vbInformation
crl.Value = Null
ElseIf crl.Tag = "D" Then
'MsgBox "Name " & crl.Name, vbInformation

crl.Value = ""
ElseIf crl.Tag = "C" Then
'MsgBox "Name " & crl.Name, vbInformation

crl.Value = ""
ElseIf crl.Tag = "E" Then
'MsgBox "Name " & crl.Name, vbInformation

crl.Value = ""
End If
Next
End With
frm.Detail.Visible = False

MsgBox "Data reset.", vbInformation

End Function

Thanks for looking.

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top