473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

I need a click event on a sub form to append a text box on the parent form

49
I have a subform with check boxes for verification of a task. I have been asked to make it so that when the check box is clicked, that it append a text box to show the particular task was done and give it a time stamp.

I am having trouble getting the click event to set the focus back to the parent form.

So I have a form called PrintServerBackups, and a subform called PrintServerCheckList. There are about 40 check boxes on the subform - which is table driven. The subform is simply a list of server names with check boxes in front of each server name.

On the parent form I have a comments box PrintServerBackups!txtComments where my user can put notes.

I would like to populate this text box with the server name and a date stamp by means of appending, when the user clicks the check box next to a server name, so a list of servers and the time stamp is created in the text box.

I set the table field for txtComments to be append only and then
I tried the following to get just one click to work for now, but ultimately I will need it to add to the text box when another check box is checked:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Forms!PrintServerBackUps!txtComments.SetFocus = True
  3. txtComments.Value = "server01: " & now()
  4.  
I also tried:
Expand|Select|Wrap|Line Numbers
  1. Me.Forms!PrintServerBackUps!txtComments.SetFocus = True
  2. Me.txtComments.Value = "server01: " & now()
  3.  
but nothing happens when I click the check box? what did I miss?

I had thought about using the =ColumnHistory on this but I don't really understand it well enough to modify it from the standard

Expand|Select|Wrap|Line Numbers
  1. =ColumnHistory([RecordSource],"txtComments","[ID]=" & Nz([ID],0))
  2.  
all I want is for the comments box to update with the server name and a date stamp each time a checkbox is checked, and I need the last entry to stay put.
Oct 30 '15 #1

✓ answered by TheSmileyCoder

Regarding Focus:
To modify a control value, that control does NOT need to have focus.

Most basic controls in Access have a .Text property, and a .Value property.

The .Text is usually used when you are validating the contents of a textbox as the user is typing, and the .Text can only be used when the control has the focus.

The .Value on the other hand can be accessed anytime.

Regarding Forms!
The Forms! collection belongs to the application. Therefore Me.Forms! doesn't make sense. Me refers to the form behind which the code is placed. From the subform, you can access the parent form in (at least) 2 ways. One is
Forms!NameOfParentForm.NameOfControl="NewValue"
the other is:
Me.Parent.NameOfControl="NewValue"

I would use the first if I was on a completely different form, i.e. a popup form, but I would always use the second approach from a subform.

Regarding txtComments and Scope
If txtComments is a control on the parent form, then you cannot from the subform use:
txtComments="somethinh"
Because the subform does not directly know of or about txtComments. However, we could use:
Me.Parent.txtComments="something"
or
Me.Parent.txtComments.Value="something"

Note that these 2 are equivalent, because the DEFAULT property of a textbox is the .Value property. Therefore most programmers tend to use the first, as it is less verbose.

Regarding Append Only
I have not played with the append only mode of a memofield from VBA. My own approach is simply to lock the control, and do it "append only" style from code.
Me.Parent.txtComments=me.Parent.txtComments & vbnewline & _
format(Date(),"yyyy-mm-dd") & ": " & "Server check"



Hope that helps.

2 1343
TheSmileyCoder
2,322 Expert Mod 2GB
Regarding Focus:
To modify a control value, that control does NOT need to have focus.

Most basic controls in Access have a .Text property, and a .Value property.

The .Text is usually used when you are validating the contents of a textbox as the user is typing, and the .Text can only be used when the control has the focus.

The .Value on the other hand can be accessed anytime.

Regarding Forms!
The Forms! collection belongs to the application. Therefore Me.Forms! doesn't make sense. Me refers to the form behind which the code is placed. From the subform, you can access the parent form in (at least) 2 ways. One is
Forms!NameOfParentForm.NameOfControl="NewValue"
the other is:
Me.Parent.NameOfControl="NewValue"

I would use the first if I was on a completely different form, i.e. a popup form, but I would always use the second approach from a subform.

Regarding txtComments and Scope
If txtComments is a control on the parent form, then you cannot from the subform use:
txtComments="somethinh"
Because the subform does not directly know of or about txtComments. However, we could use:
Me.Parent.txtComments="something"
or
Me.Parent.txtComments.Value="something"

Note that these 2 are equivalent, because the DEFAULT property of a textbox is the .Value property. Therefore most programmers tend to use the first, as it is less verbose.

Regarding Append Only
I have not played with the append only mode of a memofield from VBA. My own approach is simply to lock the control, and do it "append only" style from code.
Me.Parent.txtComments=me.Parent.txtComments & vbnewline & _
format(Date(),"yyyy-mm-dd") & ": " & "Server check"



Hope that helps.
Oct 30 '15 #2
sooli
49
THANK YOU! THANK YOU! THANK YOU!

Your explainations were supurb! and now I understand what i was missing.

I did end up having to use Forms! to make this work, without the me.

final code to work the magic i needed:

Expand|Select|Wrap|Line Numbers
  1. Forms!Printserverbackups.txtComments.SetFocus
  2. Forms!Printserverbackups.txtComments = Forms!Printserverbackups.txtComments & vbNewLine & ("archpprtp01: " & Now())
  3.  
Thank you so much for pointing out the vbNewLine snippet! this will make my life so much easier all over the place!!! You ROCK!
Oct 30 '15 #3

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

Similar topics

1
by: Sylvain | last post by:
Hi, I am developping a Visual C++ application. In my application, I created a Mdi parent form with a main menu. I also created a "menuItem" click to display a Mdi child form. I want in this case...
0
by: chenedor | last post by:
hi all i just started a new C++ .net form I ve put a basic usercontrol in it. the problem is that I want to use the clic event in my form to do several things but if i clic on the custom...
3
by: Benjamin Gavin | last post by:
Hi all, I recently stumbled upon a bug in the ASP.NET framework handling of ImageButton based postbacks. The issues derives from the fact that IE and Mozilla handle the case of a missing image...
2
by: Susan Sullivan | last post by:
How can I change properties of a child form through a parent form? I have a child form with a rich text box. I want to control font properties of the rich text box through a menu on the parent...
1
by: Marty Cruise | last post by:
Is there a way for me to subclass the menuitem class so that a parent menu item will fire the click event?
3
by: jimcolli | last post by:
I have a parent form with a menu button that has a handler. I want to call this same handler when a button on a child form is clicked. I have this simplified code in the main form's Load...
5
by: superjacent | last post by:
Hope someone can help. I have a saved parent form containing an unbound sub-form. I set the SourceObject (form) after the Parent Form opens/loads. The sub-form (datasheet view) basically...
1
by: IframeLearner | last post by:
Hi , I am trying to upload a file from a parent.jsp using Iframes. From Parent page. I have to save Subject, Desc, File and file name. to upload the file i am using Iframe. I want the...
0
by: CMELLO | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After...
7
it0ny
by: it0ny | last post by:
Hi guys, I am fairly new to visualbasic. A little background from me, I've programmed before in C++, Java, and PHP so I know programming. But I am new when it comes to GUI development too. My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.