By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,813 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,813 IT Pros & Developers. It's quick & easy.

Command button to add comments

P: 13
Hello....i'd like to have a command button on my data entry form which opens another form to allow me to add comments about that particular record.
I'd also like the same type of button on a separate form which allows me to view the existing comments for that particular record ?

Is this possible ?

Cheers
4 Weeks Ago #1

✓ answered by twinnyfo

You cannot close a subform when it is opened on a main form. Why not just make the Subform invisible?

Expand|Select|Wrap|Line Numbers
  1. Me.frm_SubComments.Visible = False

Share this Question
Share on Google+
12 Replies


NeoPa
Expert Mod 15k+
P: 31,660
It is possible, but why not have a SubForm on the Main Form, possibly on a Page (or Tab) Control, that shows the related comments so you can enter and see all related comments whenever you look at the main item?
4 Weeks Ago #2

P: 13
I only thought of this after i had the main form finished. Is there an easy way of adding a tab control and moving all my existing fields onto it ?......there's hardly any space left
4 Weeks Ago #3

NeoPa
Expert Mod 15k+
P: 31,660
Moving items onto a Page (The correct term for a Tab Control) Control is actually kind of difficult. You have to select the Control by clicking on the protruding tab with its name on and then paste in any Controls you Copied earlier.

It's really very common for people to move Controls onto a Page - just to work out later that they actually only went onto the main Form itself. Very frustrating.
4 Weeks Ago #4

P: 13
Ok thanks i'll give it a try
4 Weeks Ago #5

P: 13
Instead of adding a tabs or pages, i decided to give a subform a try. I set the form's visibility to 'No' and added a button to the main form to make the subform visible.
I used the code

Expand|Select|Wrap|Line Numbers
  1. Me.frm_SubComments.Visible = True
in the OnClick event of the button. This all works ok but when i add comments and go to close the subform with a command button it won't close ??
I used the code below on the subform command button

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdClose_Click()
  2. DoCmd.Close acForm, "frm_SubComments", acSaveYes
  3. Me.frm_SubComments.Visible = False
  4. End Sub
3 Weeks Ago #6

twinnyfo
Expert Mod 2.5K+
P: 3,355
You cannot close a subform when it is opened on a main form. Why not just make the Subform invisible?

Expand|Select|Wrap|Line Numbers
  1. Me.frm_SubComments.Visible = False
3 Weeks Ago #7

NeoPa
Expert Mod 15k+
P: 31,660
As well as making a Form as a SubForm invisible, you can also reconfigure the SubForm Control to have no associated Form ({SubFormName}.SourceObject = "") - thus causing it to disappear and be as close to closed as you'd want.
3 Weeks Ago #8

P: 13
I tried to just make it invisible but i get an error saying "Method or data member not found". The code in bold is highlighted.

Me.frm_SubComments.Visible = False

The form frm_SubComments is the name of the subform.
3 Weeks Ago #9

NeoPa
Expert Mod 15k+
P: 31,660
Pol53:
The form frm_SubComments is the name of the subform.
Nah. It really isn't.

I can only imagine that it's the name of the Form you have set in your SubForm. A SubForm is absolutely not a Form. It's a Control that you can use on a Form that contains (or displays if you prefer) a Form.

I suspect that now you understand that you'll find both approaches work smoothly for you.
3 Weeks Ago #10

P: 13
Oh i didn't know that. I still can't get it to work though....the name of the control is SubComments but it still won't close ?
3 Weeks Ago #11

NeoPa
Expert Mod 15k+
P: 31,660
At this point it would be helpful if you explained what it is you're actually trying. It may be a good post to include the code you're using.

From your comment I would assume that not closing implies it stays visible. If there is a displayed error message or other problem then you need to inform us of that.

Assuming not though, for now, just let us know what you're doing that doesn't work.
3 Weeks Ago #12

P: 13
It's ok now....i had the button on the subform but changed it to the main form and it's working now. Thanks for the assistance
3 Weeks Ago #13

Post your reply

Sign in to post your reply or Sign up for a free account.