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