Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / May 2007

Tip: Looking for answers? Try searching our database.

fill in form with predefined text by clicking a button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve - 14 May 2007 16:34 GMT
I would like to create a form that has button on it that when clicked will
populate another form with generic text. ie. when a button is clicked it put
a set of data (sentence) into another form. can this be done???
Sprinks - 14 May 2007 16:51 GMT
Steve,

What you're asking is quite straightforward, but makes me wonder what you're
trying to achieve.

In the button's OnClick event:

Dim strMyText
strMyText = "Here is my generic text."
Forms![YourOtherFormName]![YourControl] = strMyText

or if the text depends on another field on your 1st form:

strMyText
' The Case statement assumes MySelectorField is numeric
Select Case Me![MySelectorField]
    Case 1
        strMyText = "This is text for case 1."
    Case 2
        strMyText = "Case 2 text."
    ....other cases
    Case Else
        strMyText = "My default text."
End Select
Forms![YourOtherFormName]![YourControl] = strMyText

Sprinks

> I would like to create a form that has button on it that when clicked will
> populate another form with generic text. ie. when a button is clicked it put
> a set of data (sentence) into another form. can this be done???
Steve - 14 May 2007 17:02 GMT
hi Sprinks,

We have a document with various possible outcomes within the document. They
need to select one that then populates another form with the 1 option. At the
moment they have to copy/paste each one after somone has ticked the box.
Thought by creating an access form it could make it easier for them that they
tick the box and the string of text populates the form. thanks for the reply.
will try it tomorrow.

> Steve,
>
[quoted text clipped - 27 lines]
> > populate another form with generic text. ie. when a button is clicked it put
> > a set of data (sentence) into another form. can this be done???
Jerry Whittle - 14 May 2007 16:59 GMT
The code below on the On Click command of a button will work. Just put in the
right form name for Form2 and field name for txtLastUpdate. You'll probably
want to change the "Blah. Blah. Blah."

Note: The form in question must be open for this to work.

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

   [Forms]![Form2]![txtLastUpdate] = "Blah. Blah. Blah."
   
Exit_Command0_Click:
   Exit Sub

Err_Command0_Click:
   MsgBox Err.Description
   Resume Exit_Command0_Click
   
End Sub
Signature

Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

> I would like to create a form that has button on it that when clicked will
> populate another form with generic text. ie. when a button is clicked it put
> a set of data (sentence) into another form. can this be done???
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.