Copy text from Text box to text box

G

Guest

I have 2 forms. The main form (Form A) has a button that opens Form B. Form B
has a subform (Subform B) with a text box and a check box. The underlying
table [tblSTA] for Subform B has the fields: [STA] and [YES]. Form B is a
continuous form. I would like to be able to do the following:

The button on Form A opens Form B (This I have done). Form B shows a list of
multiple items (STA) with check box next to each STA. For each STA that has a
check mark, a button press would copy those items to a text box on Form A. I
would also like a second button that clears the check boxes.

The reason I do not use a list box, which I have succesfully created, is due
to the 255 character limit of each row. Some rows have 300+ characters. I
though a text box in a continuous form would circumvent the probelm, whih is
does. However, I cannot get the button on Form B or Subform B to copy checked
items.

Any help is appreciated.

- Steve
 
M

Marshall Barton

Steve said:
I have 2 forms. The main form (Form A) has a button that opens Form B. Form B
has a subform (Subform B) with a text box and a check box. The underlying
table [tblSTA] for Subform B has the fields: [STA] and [YES]. Form B is a
continuous form. I would like to be able to do the following:

The button on Form A opens Form B (This I have done). Form B shows a list of
multiple items (STA) with check box next to each STA. For each STA that has a
check mark, a button press would copy those items to a text box on Form A. I
would also like a second button that clears the check boxes.

The reason I do not use a list box, which I have succesfully created, is due
to the 255 character limit of each row. Some rows have 300+ characters. I
though a text box in a continuous form would circumvent the probelm, whih is
does. However, I cannot get the button on Form B or Subform B to copy checked
items.


Not sure what you want to end up with in the FormA text box,
but maybe this will get you started:

The Click event procedure on FormB could be something like:

With Me.subformB.RecordsetClone
.MoveFirst
Do Until .EOF
If ![YES] Then
Forms!FormA.thetextbox = (Forms!FormA.thetextbox _
+ vbCrLf) & !STA
End If
.MoveNext
Loop
End With

To clear all the checked [YES]:

With Me.subformB.RecordsetClone
.MoveFirst
Do Until .EOF
If ![YES] Then
.Edit
![YES] = False
.Update
End If
.MoveNext
Loop
End With
 
T

tina

to copy a value from the subform textbox to a mainform textbox, try the
following code in the command button's click event procedure (in the
subform), as

Me.Parent!TextboxName = Me!STA

to set the value of the YES field to False in all records in the subform,
first write a SELECT query the pulls the correct subset of records from
tblSTA. then convert the query to an Update query, setting the value of the
YES field to False. then run the query from the command button's Click event
procedure, as

CurrentDb.Execute "QueryName"

hth
 
G

Guest

Marshall,
When I run this script, I get "Method or data member not found" and the
debugger highlights "With Me.subformB.RecordsetClone" from your code. Any
suggestions?

- Steve


Marshall Barton said:
Steve said:
I have 2 forms. The main form (Form A) has a button that opens Form B. Form B
has a subform (Subform B) with a text box and a check box. The underlying
table [tblSTA] for Subform B has the fields: [STA] and [YES]. Form B is a
continuous form. I would like to be able to do the following:

The button on Form A opens Form B (This I have done). Form B shows a list of
multiple items (STA) with check box next to each STA. For each STA that has a
check mark, a button press would copy those items to a text box on Form A. I
would also like a second button that clears the check boxes.

The reason I do not use a list box, which I have succesfully created, is due
to the 255 character limit of each row. Some rows have 300+ characters. I
though a text box in a continuous form would circumvent the probelm, whih is
does. However, I cannot get the button on Form B or Subform B to copy checked
items.


Not sure what you want to end up with in the FormA text box,
but maybe this will get you started:

The Click event procedure on FormB could be something like:

With Me.subformB.RecordsetClone
.MoveFirst
Do Until .EOF
If ![YES] Then
Forms!FormA.thetextbox = (Forms!FormA.thetextbox _
+ vbCrLf) & !STA
End If
.MoveNext
Loop
End With

To clear all the checked [YES]:

With Me.subformB.RecordsetClone
.MoveFirst
Do Until .EOF
If ![YES] Then
.Edit
![YES] = False
.Update
End If
.MoveNext
Loop
End With
 
M

Marshall Barton

You have to replace "subformB" with the name of the subform
control (on the main form). If it has a space in the name,
be sure to enclose it in [ ]
--
Marsh
MVP [MS Access]


Steve said:
When I run this script, I get "Method or data member not found" and the
debugger highlights "With Me.subformB.RecordsetClone" from your code. Any
suggestions?

Steve said:
I have 2 forms. The main form (Form A) has a button that opens Form B. Form B
has a subform (Subform B) with a text box and a check box. The underlying
table [tblSTA] for Subform B has the fields: [STA] and [YES]. Form B is a
continuous form. I would like to be able to do the following:

The button on Form A opens Form B (This I have done). Form B shows a list of
multiple items (STA) with check box next to each STA. For each STA that has a
check mark, a button press would copy those items to a text box on Form A. I
would also like a second button that clears the check boxes.

The reason I do not use a list box, which I have succesfully created, is due
to the 255 character limit of each row. Some rows have 300+ characters. I
though a text box in a continuous form would circumvent the probelm, whih is
does. However, I cannot get the button on Form B or Subform B to copy checked
items.

Marshall Barton said:
Not sure what you want to end up with in the FormA text box,
but maybe this will get you started:

The Click event procedure on FormB could be something like:

With Me.subformB.RecordsetClone
.MoveFirst
Do Until .EOF
If ![YES] Then
Forms!FormA.thetextbox = (Forms!FormA.thetextbox _
+ vbCrLf) & !STA
End If
.MoveNext
Loop
End With

To clear all the checked [YES]:

With Me.subformB.RecordsetClone
.MoveFirst
Do Until .EOF
If ![YES] Then
.Edit
![YES] = False
.Update
End If
.MoveNext
Loop
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top