Re-posted: New Record after Filter

G

g

Hello experts,

This is what i've used for my subform(FormSub) to interact with my treeview
control
on the Main Form(FormMain) of my database.

Forms!FormMain.FormSub.SourceObject = "Form1"
Forms!FormMain.FormSub.Form.Filter = "SPP = Forms!FormMain.USite"
Forms!FormMain.FormSub.Form.FilterOn = True

SPP = Table column associated in Form1
Forms!FormMain.Usite = Text box control on my FormMain


And it works perfectly fine. Now I need to know how to do to make it open
(The subform) always in a new record. As of now it always open on the first
record with filtered note at the record navigator.

I tried to add DoCmd.GotoRecord , , acNewRec after my code above but it
didn't
work. Also tried to put it in on open, active, load on the Form1 event to
experiment
but it didn't work as well.

I also tried to set Data Entry to YES on Form1 but didn't help. I know there
must be away & I'm hoping you know the answer.


Thank you in advance
 
B

BruceM

Be aware that this is a volunteer newsgroup. Give it two days before you
repost. You got impatient before two hours passed.

I don't know what you mean by "treeview control", but it sounds as if you
are filtering an unrelated subform recordset to correspond to the main
form's record when you should probably have a related table. It's hard to
know since you haven't provided much information about the database
structure. The subform control's Link Child and Link Master properties need
to be set to the linking field. If you do it that way you won't need code,
and it will probably work better.

To open a recordset at a new record try:
Me.Recordset.AddNew
in the subform's Load event. If you want to be at a new subform record each
time you move to a different main form record try:
Me.FormSub.Form.Recordset.AddNew
in the main form's Current event.
 
G

g

To All:

My apology for being impatient. Not gonna happen again. Thank you Bruce for
notifying me for that, mymistake. To give you more details bout my database,
My Main Form works as a dashboard & not bound to any tables. I used treeView
Control (TreeView shows the content of my menu) instead of bottons at the
left side and an unbound subform at right side of the Main Form. If I click
one of the node of the treeView control the subform will call a function w/c
is the one I posted below. The records will be filtered & that works fine but
what I wanted to do is, after filterring the record the subform will go to a
new record automatically. Thanks again.
 
G

g

Bruce, Thank you very much for your help. The
Me.FormSub.Form.Recordset.AddNew works exactly what I need.

Thanks
 

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