fill in form with predefined text by clicking a button

S

Steve

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???
 
S

Sprinks

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
 
J

Jerry Whittle

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
 
S

Steve

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.

Sprinks said:
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

Steve said:
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???
 
Top