Copy data from one SubForm to another

R

ryguy7272

I’m working on a certain task, to copy data from one SubForm to another
SubForm. I know Access is not really designed for these kinds of things, but
there is a legitimate reason for doing this; an offsetting position on
options trades where all elements of data are almost exactly the same except
for the put/call position.

Anyway, below is the code:
Option Compare Database

Private Sub btnAddCross_Click()

Dim strCross As String
Dim ctl As Control

strCross = "TradesCrossed"
DoCmd.OpenForm strCross, acNormal, , , acFormAdd

For Each ctl In Me.Opt.Form.Controls
If ctl.Tag = "CrossData" Then
Forms(strCross).Opt.Form.Controls(ctl.Name) = ctl.Value
End If
Next ctl

End Sub

This line causes the error:
For Each ctl In Me.Opt.Form.Controls

Specifically, this part seems to be causing the problem:
..Opt

Someone pointed out that the Form, which works as a SubForm within a Form,
may be named something other than ‘Opt’ but I don’t know how that can be
possible. If I go into Design View in the Form named ‘Trades’ and click on
the SubForm named ‘Opt’, in the Properties, the name really is ‘Opt’.

This is sitting behind a Form named ‘Opt’, and this is embedded as a SubForm
in a Form named ‘Trades’. I have another Form, named ‘OptCrossed’, and this
is embedded as a SubForm in a Form named ‘TradesCrossed’.

I want to click a Button named ‘btnAddCross’ and copy the data from ‘Opt’ to
‘OptCrossed’. The data that feeds ‘Opt’, i.e., the Record Source, is called
‘QueryWorking’ (just a silly name I came up with to test this). I don’t
think the name of the Record Source is relevant, but I just wanted to throw
it out there.

Some of you reading this may recognize this post from about 1 months ago. I
thought this was kind of working, but actually, this never really worked
right.

Any thoughts on how to make this thing work?

Thanks so much!
Ryan--
 
P

pietlinden

I’m working on a certain task, to copy data from one SubForm to another
SubForm.  I know Access is not really designed for these kinds of things, but
there is a legitimate reason for doing this; an offsetting position on
options trades where all elements of data are almost exactly the same except
for the put/call position.  

Stupid question, but why not just use a parameterized append query
and requery the subform that is based on the table you are appending
to? If you think of the forms as windows to your data, then skip the
windows and go straight for the tables underneath...
 
R

ryguy7272

Ok, let's say I have 100 records. I go to record 101, add new data, and I
want to click a Button and a new Form, with accompnaying SubForm opens...will
the parameterized append query show me the record for 101 in the new
Form/SubForm? If yes, how do I set this up?

Thanks!
Ryan--
 
R

ryguy7272

Is there anything else to this? Am I missing something? it doesn't seem
like it should be a difficult thing, but actually it is turning out to be
kind of a difficult thing. Any other ideas as to how I may do this?

Thanks again,
Ryan---
 

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