Hidden Subform, need NewRecord on Visible

R

Ripper

I have a hidden subform that is linked to an unbound combo-box. Once I
determine that information is needed, I click a button to set the subform to
visible. No problem. However, I want the unhidden for to go to a new record
once it becomes visible.

How to I do that in the button's VBA or in which subform Even to I place the
New Record code?
 
D

Dirk Goldgar

Ripper said:
I have a hidden subform that is linked to an unbound combo-box. Once I
determine that information is needed, I click a button to set the subform
to
visible. No problem. However, I want the unhidden for to go to a new
record
once it becomes visible.

How to I do that in the button's VBA or in which subform Even to I place
the
New Record code?


You might do it with code like this in your button's Click event:

'----- start of example code -----
Private Sub cmdShowSubform_Click()

With Me!sfYourSubformControl
.Recordset.AddNew
.Visible = True
End With

End Sub
'----- end of example code -----

You need to replace "cmdShowSubform" with the name of your command button,
and "sfYourSubformControl" with the name of your subform control; that is,
the name of the control on the main form that will display the subform.
 
R

Ripper

When I tried to use that code I received a Runtime 438 "object doesn't
support this property or method" error. I am using Access 2003 with 2000 as
the backend. Any ideas.
 
D

Dirk Goldgar

Ripper said:
When I tried to use that code I received a Runtime 438 "object doesn't
support this property or method" error. I am using Access 2003 with 2000
as
the backend. Any ideas.


Sorry, I left out a .Form qualifier. Try this:

'----- start of example code -----
Private Sub cmdShowSubform_Click()

With Me!sfYourSubformControl
.Form.Recordset.AddNew
.Visible = True
End With

End Sub
'----- end of example code -----
 

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