[SOLVED] Update textbox with value from Form Field


"Excel VBA Help"

 


Play Friv Now - Play Friv Games
Go Back   The Code Cage Forums > Microsoft Topics > Microsoft Word Forum
Our Info Pages:-
The Code Cage - Microsoft Office help

Notices

Microsoft Word Forum Members, post questions in this forum if they are related to using Microsoft Word, this includes Document Properties, VBA Programming & Functionality etc.

 
 
Thread Tools Rate Thread Display Modes
  #1  
Old 25th February 2014, 13:09
sharky12345's Avatar
sharky12345 sharky12345 is offline
Junior Member
MS Office Version: MS Office 97, 2003, 2007,2010
MS Office Skill Level: Some VBA experience
 
Join Date: Oct 2013
Location: UK
Posts: 54
Posts Per Day: 0.04
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Reputation: 10 (5) sharky12345 is on a distinguished road
Default Update textbox with value from Form Field
     Word: VBA   


------ Register to get rid of these "In Post" ads! ------

Category: Word: VBA   

I'm using this to update a Form Field with a textbox value;

VBA CODE:
ActiveDocument.FormFields("txtdateform").Range.InsertBefore _ 
txtdate.Value 

What I can't work out is how to abandon the update if the Form Field already has a value if someone can help?



The Code Cage Advertisment
Advertisement
  #2  
Old 25th February 2014, 15:19
RoyUK's Avatar
RoyUK RoyUK is offline
Administrator
Solution Centre Professional
MS Office Version: MS Office 2003, 2007, 2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Nov 2008
Location: Derbyshire, UK
Posts: 2,707
Posts Per Day: 0.81
My Top Tip Count: 4
Thanks to others: 2
Thanked 195 Times in 193 Posts
Reputation: 3320 (70) RoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond repute
4 Top Tips
England
Default Re: Update textbox with value from Form Field

------ Register to get rid of these "In Post" ads! ------


maybe

VBA CODE:
If Trim(ActiveDocument.FormFields("txtdateform").Result) = "" Then _ 
ActiveDocument.FormFields("txtdateform").Range.InsertBefore txtdate.Value 
__________________
Hope that helps, RoyUK
For tips & examples visit free excel help
DatabaseForm
About me



  #3  
Old 25th February 2014, 15:39
sharky12345's Avatar
sharky12345 sharky12345 is offline
Junior Member
MS Office Version: MS Office 97, 2003, 2007,2010
MS Office Skill Level: Some VBA experience
 
Join Date: Oct 2013
Location: UK
Posts: 54
Posts Per Day: 0.04
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Reputation: 10 (5) sharky12345 is on a distinguished road
Default Re: Update textbox with value from Form Field

------ Register to get rid of these "In Post" ads! ------


Roy, Thank you but it is not working - not because your suggestion doesn't work, but more like my original code is not doing what I thought it would.....

When the text is originally put into the document, it is appearing to the left of the form field and therfore when the 'IF' is tested it is finding an empty form field and entering the data again.

Any idea why this would happen? I thought my original code would populate the form field, (the shaded box), but it doesn't, as above.



The Code Cage Advertisment
Advertisement
  #4  
Old 26th February 2014, 07:52
RoyUK's Avatar
RoyUK RoyUK is offline
Administrator
Solution Centre Professional
MS Office Version: MS Office 2003, 2007, 2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Nov 2008
Location: Derbyshire, UK
Posts: 2,707
Posts Per Day: 0.81
My Top Tip Count: 4
Thanks to others: 2
Thanked 195 Times in 193 Posts
Reputation: 3320 (70) RoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond repute
4 Top Tips
England
Default Re: Update textbox with value from Form Field

------ Register to get rid of these "In Post" ads! ------


Is the text entered manually?
__________________
Hope that helps, RoyUK
For tips & examples visit free excel help
DatabaseForm
About me



  #5  
Old 26th February 2014, 09:01
sharky12345's Avatar
sharky12345 sharky12345 is offline
Junior Member
MS Office Version: MS Office 97, 2003, 2007,2010
MS Office Skill Level: Some VBA experience
 
Join Date: Oct 2013
Location: UK
Posts: 54
Posts Per Day: 0.04
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Reputation: 10 (5) sharky12345 is on a distinguished road
Default Re: Update textbox with value from Form Field

------ Register to get rid of these "In Post" ads! ------


No - it's entered using the value from a textbox on a userform.



  #6  
Old 26th February 2014, 12:51
RoyUK's Avatar
RoyUK RoyUK is offline
Administrator
Solution Centre Professional
MS Office Version: MS Office 2003, 2007, 2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Nov 2008
Location: Derbyshire, UK
Posts: 2,707
Posts Per Day: 0.81
My Top Tip Count: 4
Thanks to others: 2
Thanked 195 Times in 193 Posts
Reputation: 3320 (70) RoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond repute
4 Top Tips
England
Default Re: Update textbox with value from Form Field

------ Register to get rid of these "In Post" ads! ------


I don't know much about Word VBA but is the userform posting correctly?
__________________
Hope that helps, RoyUK
For tips & examples visit free excel help
DatabaseForm
About me



The Code Cage Advertisment
Advertisement
  #7  
Old 26th February 2014, 12:53
sharky12345's Avatar
sharky12345 sharky12345 is offline
Junior Member
MS Office Version: MS Office 97, 2003, 2007,2010
MS Office Skill Level: Some VBA experience
 
Join Date: Oct 2013
Location: UK
Posts: 54
Posts Per Day: 0.04
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Reputation: 10 (5) sharky12345 is on a distinguished road
Default Re: Update textbox with value from Form Field

------ Register to get rid of these "In Post" ads! ------


Not sure Roy - just dabbling myself but learning lots as I go along. It's not a huge problem if I can't resolve it, just thought I'd give it a try....



  #8  
Old 4th March 2014, 08:13
macropod's Avatar
macropod macropod is offline
Solution Centre Professional
MS Office Version: MS Office 2000, 2003 & 2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 172
Posts Per Day: 0.07
My Top Tip Count: 0
Thanks to others: 0
Thanked 20 Times in 20 Posts
Reputation: 380 (11) macropod is just really nicemacropod is just really nicemacropod is just really nicemacropod is just really nice
Australia
Default Re: Update textbox with value from Form Field

------ Register to get rid of these "In Post" ads! ------


ActiveDocument.FormFields("txtdateform").Result.Text = txtdate.Value
__________________
Cheers,
Paul Edstein
[MS MVP - Word]



  #9  
Old 4th March 2014, 08:13
macropod's Avatar
macropod macropod is offline
Solution Centre Professional
MS Office Version: MS Office 2000, 2003 & 2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 172
Posts Per Day: 0.07
My Top Tip Count: 0
Thanks to others: 0
Thanked 20 Times in 20 Posts
Reputation: 380 (11) macropod is just really nicemacropod is just really nicemacropod is just really nicemacropod is just really nice
Australia
Default Re: Update textbox with value from Form Field

------ Register to get rid of these "In Post" ads! ------


ActiveDocument.FormFields("txtdateform").Result.Text = txtdate.Value
__________________
Cheers,
Paul Edstein
[MS MVP - Word]



The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!

  #10  
Old 4th March 2014, 08:17
sharky12345's Avatar
sharky12345 sharky12345 is offline
Junior Member
MS Office Version: MS Office 97, 2003, 2007,2010
MS Office Skill Level: Some VBA experience
 
Join Date: Oct 2013
Location: UK
Posts: 54
Posts Per Day: 0.04
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Reputation: 10 (5) sharky12345 is on a distinguished road
Default Re: Update textbox with value from Form Field

------ Register to get rid of these "In Post" ads! ------


Thanks Paul!



The Code Cage Advertisment
Advertisement
 
The Code Cage at Facebookhe Code Cage at Twitter


Tags
field, form, textbox, update

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

The Code Cage Affilliates



http://www.thecodecage.com/forumz tested by McAfee Security http://www.thecodecage.com/forumz tested by McAfee Security

All times are GMT +1. The time now is 04:40.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Template-Modifications by TMS
No part of this board, functionality or creatives may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
Copyright ©2008 - , Simon lloyd.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application they represent and are used with permission from Microsoft
UA-8135493-1
Cultural Forum | Study at Malaysian University
X vBulletin 3.8.7 Debug Information
  • Page Generation 0.20953 seconds
  • Memory Usage 6,611KB
  • Queries Executed 15 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footerEnd
  • (1)ad_footerStart
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_headerEnd
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_leftcolumn_code
  • (1)ad_navbar_below
  • (5)ad_postbit_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (10)helpful_answers
  • (1)helpfulanswers_javascript
  • (1)navbar
  • (3)navbar_link
  • (3)navbar_noticebit
  • (52)option
  • (10)post_thanks_box
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_ctoptip
  • (10)postbit_onlinestatus
  • (46)postbit_reputation
  • (10)postbit_wrapper
  • (1)showthread_changepostsowner_link
  • (1)showthread_extra_fields
  • (1)showthread_quickreply_mrgdp
  • (1)showthread_reason_popup
  • (1)spacer_close
  • (1)spacer_open
  • (1)su_form
  • (4)tagbit
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_datastore.php
  • ./includes/class_hook.php
  • ./awcoding/plugins/awc.php
  • ./awcoding/plugins/ds.php
  • ./awcoding/plugins/ss.php
  • ./includes/functions_notice.php
  • ./mobiquo/smartbanner.php
  • ./mobiquo/include/classTTConnection.php
  • ./mobiquo/smartbanner/head.inc.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/vbatags.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php
  • ./includes/functions_misc.php 

Hooks Called:
  • init_startup
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_check_criteria
  • notices_noticebit
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • helpfulanswers_showthreadorpost
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • helpfulanswers_show_normal
  • reputation_power
  • reputation_image
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • error_fetch
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete