Enter text in an ubound text box

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

I have a for where I want the user to search for the data
that they want and then click a button which will
transfer the data over to another form that can be
printed. Why won't this work:

'saves the name into the variable FullName
Dim FullName As String
FullName = [Full Name]

'Opens the new form that will be printed
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Print Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

'Enters the variable 'FullName' into the unbound
'text box call 'Name'
Me.Name = FullName

This keeps telling me that the field can't be updated.
All I want it to do is transfer the text over to the new
form where the user can print it without saving it. I
checked the value of the variable 'FullName' by insering
msgboxes and it has the correct value all the way
through. It won't insert the value of the
variable 'FullName' into the unbound text box.
 
The problem may be here:

'Enters the variable 'FullName' into the unbound
'text box call 'Name'
Me.Name = FullName

When you use the expression: Me.Name Access will think you are
referring to the Name of the Form. "Name" is a reserved word in Access,
meaning that it is already being used for something and Access does not want
you to use it. Try naming your form's unbound text box to: txtName or
somesuch

Also, here is a link to Reserved Words in Access 2000:

http://support.microsoft.com/default.aspx?scid=kb;en-us;209187

You can find the Reserved Words for other versions of Access by searching at
http://support.microsoft.com
 
The statement Me.Name = FullName is being interpreted as a
call to change the name of the current form to the contents
of the variable FullName. If you wsih to set the contents
of the control called Name on the form "Print Form", then try
Forms("Print Form")![Name] = FullName

Hope This Helps
Gerald Stanley MCSD
 
You are not inserting FullName into the new form this way. The focus of
this code is still the original form. In order for the fullname to be put
in the text box in the NEW form, you have to put this code

'Enters the variable 'FullName' into the unbound
'text box call 'Name'
Me.Name = forms!theoldform![Full Name]

in the *new* form, say in the OnOpen or OnLoad event.

The other way is to send the string value to the new form with the OpenArgs:

DoCmd.OpenForm stDocName, , , stLinkCriteria, , , FullName

and then in the OnLoad Event of the new form, have code like this:

Me.Name= Me.openargs

On my website, see sig below, is a small sample database called OpenArgs.mdb
which demonstrates this.
 
If that code is the On Click event of the button, it can
open a form but cannot easily (or maybe not at all?)
perform an action upon that form. Probably best if you
use a report for printing, by the way. If I understand
correctly what you are trying to do, I think that you
might do best to have the record source for the control
(text box?) on the report (or printable form) be the same
as for the found data on the original form.
Alternatively, you could have the control's record source
be the control on the form (assuming the form is still
open) thus: Forms!YourFormName!FullName.
You don't say how the user searches for data, but if it is
from something like a combo box that displays the data on
the form, and if the information you want printed appears
on the form, use that same record source in your report.
You could also set the value of the control in the
report's (or printable form's) On Open event, but I don't
see that having an advantage over using the record source
as described above.
 
Is there anyway that I could transfer the information
when the user clicks a button if I use a report and still
have unbound text boxes?
-----Original Message-----
You are not inserting FullName into the new form this way. The focus of
this code is still the original form. In order for the fullname to be put
in the text box in the NEW form, you have to put this code

'Enters the variable 'FullName' into the unbound
'text box call 'Name'
Me.Name = forms!theoldform![Full Name]

in the *new* form, say in the OnOpen or OnLoad event.

The other way is to send the string value to the new form with the OpenArgs:

DoCmd.OpenForm stDocName, , , stLinkCriteria, , , FullName

and then in the OnLoad Event of the new form, have code like this:

Me.Name= Me.openargs

On my website, see sig below, is a small sample database called OpenArgs.mdb
which demonstrates this.

--
--Roger Carlson
www.rogersaccesslibrary.com
Reply to: Roger dot Carlson at Spectrum-Health dot Org


I have a for where I want the user to search for the data
that they want and then click a button which will
transfer the data over to another form that can be
printed. Why won't this work:

'saves the name into the variable FullName
Dim FullName As String
FullName = [Full Name]

'Opens the new form that will be printed
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Print Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

'Enters the variable 'FullName' into the unbound
'text box call 'Name'
Me.Name = FullName

This keeps telling me that the field can't be updated.
All I want it to do is transfer the text over to the new
form where the user can print it without saving it. I
checked the value of the variable 'FullName' by insering
msgboxes and it has the correct value all the way
through. It won't insert the value of the
variable 'FullName' into the unbound text box.


.
 
Is there anyway that I could transfer the information
when the user clicks a button if I use a report and still
have unbound text boxes?
 
As long as the form that you are calling the report from remains open, you
can simply refer the unbound text box control to a control on the form.
Assume you have a control on your report called txtFullName. The control
source would be:

=Forms!MyForm![Full Name]

This will insert the value of the textbox (Full Name) on the form (MyForm)
and display it in the txtFullName control on the report.

--
--Roger Carlson
www.rogersaccesslibrary.com
Reply to: Roger dot Carlson at Spectrum-Health dot Org

Dan said:
Is there anyway that I could transfer the information
when the user clicks a button if I use a report and still
have unbound text boxes?
-----Original Message-----
You are not inserting FullName into the new form this way. The focus of
this code is still the original form. In order for the fullname to be put
in the text box in the NEW form, you have to put this code

'Enters the variable 'FullName' into the unbound
'text box call 'Name'
Me.Name = forms!theoldform![Full Name]

in the *new* form, say in the OnOpen or OnLoad event.

The other way is to send the string value to the new form with the OpenArgs:

DoCmd.OpenForm stDocName, , , stLinkCriteria, , , FullName

and then in the OnLoad Event of the new form, have code like this:

Me.Name= Me.openargs

On my website, see sig below, is a small sample database called OpenArgs.mdb
which demonstrates this.

--
--Roger Carlson
www.rogersaccesslibrary.com
Reply to: Roger dot Carlson at Spectrum-Health dot Org


I have a for where I want the user to search for the data
that they want and then click a button which will
transfer the data over to another form that can be
printed. Why won't this work:

'saves the name into the variable FullName
Dim FullName As String
FullName = [Full Name]

'Opens the new form that will be printed
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Print Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

'Enters the variable 'FullName' into the unbound
'text box call 'Name'
Me.Name = FullName

This keeps telling me that the field can't be updated.
All I want it to do is transfer the text over to the new
form where the user can print it without saving it. I
checked the value of the variable 'FullName' by insering
msgboxes and it has the correct value all the way
through. It won't insert the value of the
variable 'FullName' into the unbound text box.


.
 
Back
Top