Hide [and seek], part III


G

Guest

Hello,

I have a continuous subform that shows records from a table [not the table
the parent form is based on] - a check box, a text field with text, and a
blank text field for notes.

When I click on one particular of the checkboxes I see in form view, I can
make the notes field/s visible. Unfortunately, that means right now that the
fields for all the records become visible.
If at all possible, I would like to set this up so that only one particular
text box becomes visible.

Could somebody please tell me if this can be done, and help me do it?

Thanks a lot.
 
Ad

Advertisements

A

Albert D. Kallal

No, you can't really do that.

You could place a big text box on the right side that is NOT part of the
continues form, and dispay the text there (this would invoivle two sub-forms
side by side).

I certainly have a lot of continues forms where I set the controls 'enabled'
property on/off. While this actually makes all instances of the control go
disabled, I actually find this works quite well. I mean, when you move
to the next row, those columns that you enable, or disable can then
be set. So, you could set the controls visible property as you move
the cursor up/down through the

In fact, I actually PREFER the above behavior, as then during
data entry it is VERY easy to see that the column in question
is enabled.

In place of a VERY HARD TO READ checkerboard pattern of enabled, and
disabled boxes,
, you get a very nice enable/display view as I move the cursor up /down.

I have uploaded a gif animation of me navigating in a form, both of the two
screen shots will give you an idea of how this looks.

http://www.members.shaw.ca/AlbertKallal/HideColumn/index.htm

So, take a look at the above, but in your case, I don't think the above
hide/show will apply very well.
 
G

Guest

That looked interesting.

But I also don't think your solution applies to my situation.
I have a questionnaire and sometimes there's a "question" called "other"
where people are to input text. Unfortunately, the questions/records that can
have text input are not always at the end of the continuous form so working
with multiple subforms would be awkward at best.
Actually, I initially thought I could just tell people to tab from the
checkbox to the text field, but I'v encountered some strange behaviour with
this where pressing the tab key will move the focus not to the text field but
to a different subform. Very odd.
But maybe I could place a single textbox next to the "other" type questions
and have its contents copied into the table on Lost Focus or AfterUpdate.

Thanks for your reply.
 
A

Albert D. Kallal

But maybe I could place a single textbox next to the "other" type
questions
and have its contents copied into the table on Lost Focus or AfterUpdate.
Well, yes. (great idea..and kind of what I was suggestion).

On the left side of the screen you have a continues form...

and on the right side, you have a LARGE text box, likely the SAME height as
the continues sub-form on the left side.

As the user navigations up/down the continues form, any record that has (or
needs) text can enable the huge text box on the right side.

And, in place of shuffling the data in/out of that large text box, you just
bind it to the table for edting (less work).


You can use the continues forms "on current" event....


if me.MustHaveTextbox = True then

me.parent.BigTextBox.Visible = true
me.parent.RecordSource = "seelect * from mytable where id = " & me!ID
else
me.parent.BigTextBox.visible = false
end if

Note that you likely will need to force a update when the focus changes from
the left side to the right side....
 
G

Guest

Ah, interesting.
This is what I have come up on my own. Looks like my idea my be a bit
overcomplicated compared to yours . :)
__

Private Sub Answer_AfterUpdate()

If Me.Answer = -1 And Me.QuestionID = 12 Then
Forms!frmBrowseApplications.NoteText.Visible = True
End If

If Me.Answer = 0 And Me.QuestionID = 12 Then
Forms!frmBrowseApplications.NoteText.Visible = False
End If

End Sub

Private Sub Form_current()

If DLookup("[Answer]", "tblActivityAnswers", "[ActivityID] = " &
Forms!frmBrowseApplications![ActivityID] & " AND [QuestionID] = 12") = True
Then
Forms!frmBrowseApplications.NoteText.Visible = True
Else: Forms!frmBrowseApplications.NoteText.Visible = False

End If

End Sub
__

And in my text box - which at this point is unbound - I have this:

Private Sub NoteText_AfterUpdate()

Me!sfrmTargetAudience![Note] = Me.NoteText
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

End Sub
__

That seems to work, at least as long as I enter data right after I check the
checkbox because then the correct record has the focus and the text will be
saved in the right place.
Not sure yet how this will work if the text has to be edited later.
 
Ad

Advertisements

G

Guest

Thank you, I shall take a look at that.

Peter Hibbs said:
You could probably do this using a Flex Grid control but it would involve a
fair amount of VBA coding. See :-

http://www.rogersaccesslibrary.com/OtherLibraries.asp#Hibbs,Peter S

for some examples of using the Flex Grid control in Access.
--
Peter Hibbs


Niniel said:
Hello,

I have a continuous subform that shows records from a table [not the table
the parent form is based on] - a check box, a text field with text, and a
blank text field for notes.

When I click on one particular of the checkboxes I see in form view, I can
make the notes field/s visible. Unfortunately, that means right now that the
fields for all the records become visible.
If at all possible, I would like to set this up so that only one particular
text box becomes visible.

Could somebody please tell me if this can be done, and help me do it?

Thanks a lot.
 
G

Guest

Hello Albert,

Thanks for your suggestions.
Unfortunately, I didn't quite understand this part:

me.parent.RecordSource = "seelect * from mytable where id = " & me!ID

So after a lot of experimentation I ended up with the following. It seems to
work, with only one problem:
___

Private Sub Answer_AfterUpdate()

If Me.Answer = -1 And Me.QuestionID = 12 Then
Me.Parent.NoteText.Visible = True
End If

If Me.Answer = 0 And Me.QuestionID = 12 Then
Me.Parent.NoteText.Visible = False
End If

End Sub

Private Sub Form_current()

If DLookup("[Answer]", "tblActivityAnswers", "[ActivityID] = " &
Me.Parent.[ActivityID] & " AND [QuestionID] = 12") = True Then
Me.Parent.NoteText.Visible = True
Me.Parent.NoteText = DLookup("[Note]", "tblActivityAnswers", "[ActivityID] =
" & Me.Parent.[ActivityID] & " AND [QuestionID] = 12")
Else: Me.Parent.NoteText.Visible = False
End If

End Sub
__

And that problem is that this all only does what it is supposed to be doing
when the checkbox that unhides the text field is still active.
But if somebody clicks on another checkbox and then decided to edit the text
field, the information is stored with the wrong record, ie. the one
belonging to currently active checkbox.
I'm not sure if anything can be done about that. Or is there a way to switch
focus to the correct check box the moment the text box is clicked?
 
Ad

Advertisements

G

Guest

Ok, this is now working. May not be pretty or very efficient, but it does
what I want done, so I'm happy. :)
Thank you very much for your assistance.

On my parent form:

Private Sub NoteText1_AfterUpdate()

'Copy text from text field to table and save record

DoCmd.RunSQL "Update tblActivityAnswers Set [Note] =
Forms!frmBrowseApplications.[NoteText1] WHERE [ActivityID] =
Forms!frmBrowseApplications.[ActivityID] And [QuestionID] = 12"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

End Sub
___

On my subform:

Private Sub Answer_AfterUpdate()

If Me.Answer = -1 And Me.QuestionID = 12 Then
Me.Parent.NoteText1.Visible = True
End If

If Me.Answer = 0 And Me.QuestionID = 12 Then
Me.Parent.NoteText1.Visible = False
End If

End Sub


Private Sub Form_current()

If DLookup("[Answer]", "tblActivityAnswers", "[ActivityID] = " &
Me.Parent.[ActivityID] & " AND [QuestionID] = 12") = True Then
Me.Parent.NoteText1.Visible = True
Me.Parent.NoteText1 = DLookup("[Note]", "tblActivityAnswers", "[ActivityID]
= " & Me.Parent.[ActivityID] & " AND [QuestionID] = 12")
Else: Me.Parent.NoteText1.Visible = False
End If

End Sub
 

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