Link to home
Start Free TrialLog in
Avatar of mytfein
mytfein

asked on

datasheet - question 9 - datasheet as a subform

Hi EE,

a) Background:
==========
I have a datasheet as a subform, that is not connected by a key to the parent form.
On the parent form on have a control called: Notes
When the entire form open, the datasheet is displayed AND the Notes field is HIDDEN.

b) I would like:
   when user clicks on a row in a datasheet,
           to SHOW the Notes field with additional info for that row.

c) I created an event for the Subform's detail section: click event

Private Sub Detail_Click()

Me!txtName.Visible = True
Me!lblNotes.Visible = True
Me!txtNotes.Visible = True

End Sub

d) I set a breakpoint in the above event, BUT the event is not firing when I click on a row
in the datasheet.

Any advice, pls, tx, sandra
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Try clicking on a Record Selector (far left) and see if it works?

mx
Avatar of mytfein
mytfein

ASKER

good morning,

mx, tried your idea, click event did not fire... sigh...

tx, s
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mytfein

ASKER

Hi mx,
It's a nice idea.
I put it on the subform's On Current Event.

When I clicked to change from design to form view:
   The On Current event fired about 3 times
        wonder why? i wish it would not fire at all, unless user clicked on the row

On another post, you provided this link:
http://www.lebans.com/conditionalformatting.htm

It says he is providing logic for current row for datasheet view.
So maybe your idea is possible, but am missing something...

maybe it's time for me to dig into his mdb... '
have you used his technique, if so, perhaps your code can fastpath me towards this goal?
tx, s

Avatar of mytfein

ASKER

hi mx,
i'm experimenting with the on current for datasheet form in:

http://www.lebans.com/conditionalformatting.htm

i have casual knowledge of custom classes.
i think i followed instructions, but it is not working for me.

do you have experience with this, i'll pick it up again tommorrow, be well, tx, s

I have tried Steven's CF row highlite ... and it works, but seemed to be a bit slow in refreshing for some cases.  It's been a while.

But, lets back up.  We are dealing with a notes field on the Main form, right?  And when the user click in a row on the datasheet, you want to see the Notes for that row ... on the Main form ?  Guess I'm not quite sure what you need here.  

The Leban's app isn't directly related to this as far as I can tell ... ?

mx
Avatar of mytfein

ASKER

hi mx,

yes you are right - just want to display the Notes field on main form, when user click's on row

i just thought, if i could understand Steve's technique of:
    he has another form in the conditionalformatting2k mdb
                             to color the current row in a datasheet

then i could just modify that logic:
       instead of coloring the current row

just: display the notes field

tx, s
ok ... just to be clear, when you say 'display' ... are there notes in each row in the datasheet?  and you want to notes from each row to 'display' in a text box on the main form?  Like maybe a bigger text box?

mx
Avatar of mytfein

ASKER

hi mx,
yes
notes is a field in the record

want to display notes in a field on the main form.

you know, i tried the on enter_event,   it fires when i click on the data cell
but the NOTES is a bound field and is displaying the contents of the FIRST RECORD, and
not the ON CURRENT's notes value... sigh.... tx, s

'Private Sub txtLevelChangeTimeStamp_Enter()
'
'Forms!frmMaintain_Levels_Datasheet!lblNotes.Visible = True
'Forms!frmMaintain_Levels_Datasheet!txtNotes.Visible = True
'Forms!frmMaintain_Levels_Datasheet!txtName.Visible = True
'
'End Sub



ok ... couple more questions:

1) what is the name of the notes text box on the main form

2) what is the name of the notes text box control on the datasheet subform

3) Is the notes text box on the main form 'unbound', ie no Control Source ?

mx
Avatar of mytfein

ASKER

1) what is the name of the notes text box on the main form
      txtNotes

2) what is the name of the notes text box control on the datasheet subform
      It's not on the datasheet form.  - that's  why i am wishing to click on row, and fill in a large notes
         control on the main form

3) Is the notes text box on the main form 'unbound', ie no Control Source ?
      It's bound to:   Notes

mx, you and andrew have been really kind to me about this issue. thx sooo much,
am leaving for the day... will be in touch on Monday... tx, s
Avatar of mytfein

ASKER

Hi mx,
sorry, have been out of touch....

using your idea of the On Current Event  and a web link, which I will mention below, I realized that
the On Current event on the subform DOES work, I just did not code it correctly,
the code in the code window works, bec. I'm referring to parent name along with the parent's control.
The code in the window shows the:
   SUBFORM affecting  the PARENT FORM's control.

so let's split points, tx, s




Private Sub Form_Current()
 
Debug.Print "here ", Me!txtFullName
 
Dim frm As Form
Set frm = Forms!frmStudents
 
frm.txtName = Me!txtFullName
frm.txtNotes = Me!txtNotes
 
End Sub

Open in new window

Avatar of mytfein

ASKER

awarding you full points bec. EE does not let me award myself points -
tx again for your help, s
Avatar of mytfein

ASKER

Dear Public,
I was not allowed to award myself points, as I posted the quest.
I awarded mx the points bec. he started the solution,
    and the working solution is in the code window above.

tx, sandra
As a side note .... Sandra gets big kudos for:

1) Being attentive and staying on top of her question (quick responses, etc).
2) Fairness in grading / assigning points.

Welcome to EE Sandra ...

mx
Avatar of mytfein

ASKER

Thx guys...

I have a colleague that inspired me with an idea and i found documentation of his idea in the weblink
below that i forgot to mention in my posting above:
    http://bytes.com/topic/access/answers/852267-detecting-sub-form-event-main-form

look at reply # 11 -  Here the pgmrs wants the PARENT'S form ======> to affect the SUBFORM
                                so WITHEVENTS gives the parent form access to the subform's events

                                (My EE post -                     want SUBFORM ==========> to affect PARENT's form....)

So I thought to myself look's like the ON CURRENT event of subform DOES fire.
So what am I doing wrong with mx's ON CURRENT solution?

You see, I did not have prev. experience with subforms or datasheet forms,
                              I just worked with full size forms.
               One form would open another when user would click command button.
               The opened form could access info from the prev. form (which is hidden) by doing:

Dim frm As Form
Set frm = Forms!frmStudents
 
frm.txtName = Me!txtFullName
frm.txtNotes = Me!txtNotes

so I popped this code into the SUBFORM's on open event, and it worked....
tx, s    
Avatar of mytfein

ASKER

correction:
THIS SENTENCE IS INCORRECT:
   so I popped this code into the SUBFORM's on open event, and it worked....

SHOULD BE:
   so I popped this code into the SUBFORM's    *** ON CURRENT event ***,   and it worked....