based on everything you've told me,
[strCardNum]=[strCardNum] And [strShootDate]=[strDate] And
[strShootTime]=[strTime]
should work. that's assuming that the names on the *left* side of each "="
pair are the correct names of the fields in in the RecordSource of
frmShootInfo; and the names on the *right* side of each "=" pair are the
correct names of the controls in the subform.
but it seems like people have more trouble getting control references to
work in macros, especially when subforms are involved. at this point, i'd
just throw up my hands and do it in VBA. again, if the command button is on
the subform (the location where a code, or macro, is called from makes a big
difference), add the following code to the button's Click event procedure,
as
DoCmd.OpenForm "frmShootInfo ", , , "strCardNum = '" _
& Me!strCardNum & "' And strShootDate = '" _
& Me!strDate & "' And strShootTime = '" & strTime & "'"
since all the fields are prefixed with "str", the above handles them all as
Text data types. if a field is a Number data type, the correct syntax would
leave off the single quotes, as
"strCardNum = " & Me!strCardNum
if a field is a Date/Time data type, the correct syntax would replace the
single quotes with the # sign, as
strShootDate = #" & Me!strDate & "#
if you don't know how to create an event procedure to house the code, post
back and i'll walk you through it, it's not hard.
hth
Mark said:
Still not working. :/ Let me list all the parts of the problem.
3 forms:
frmPersonalInfo (the main form)
main information pulled from here is the ID Card Number (strCardNum)
frmNameSelect (the sub-form, in frmPersonalInfo)
pulls information from a name-to-date table, listing ID card numbers,
dates, and times (strCardNum, strDate, strTime)
frmShootInfo (the form I wish to open with the OpenForm macro)
contains the ID card number, dates, and times used to populate the
name-to-date table
The macro only has the one action, the OpenForm, with the where condition as
you said to enter it above. It still acts as if it cannot find the
information to use to filter the results.
Does this help a little more? Thanks for the help already, btw!
tina said:
well, on reading your original post again, it sounds like you have FormA
open. you also have FormB open, and FormB has a subform in it. you want to
refer to controls within the subform that's on FormB - to filter records on
FormA.
assuming that the command button is on the subform itself (not on FormB),
try the following syntax, as
[strCardNum]=[strCardNum] And [strShootDate]=[strDate] And
[strShootTime]=[strTime]
if the command button is on FormB (not on the subform itself), then try
[strCardNum]=[frmNameSelect].Form![strCardNum] And
[strShootDate]=[frmNameSelect].Form![strDate] And
[strShootTime]=[frmNameSelect].Form![strTime]
the above syntax also assumes that the name of the *subform CONTROL* in
FormB is [frmNameSelect]. you need to double check, because sometimes the
name of a subform object in the database window is NOT the same as the name
of the subform control in the main form.
to check the subform control name in FormB: open the form in design view,
and click on the subform (within FormB's design view) ONCE to select it. in
the Properties box, click on the Other tab and look at the Name property.
hth
Macro is very simple, just an OpenForm with no conditional statements. It
is
set to the OnClick event for a button. The only argument is the Where
Condition, which is as follows:
[strCardNum]=[Forms]![frmNameSelect]![strCardNum] And
[strShootDate]=[Forms]![frmNameSelect]![strDate] And
[strShootTime]=[Forms]![frmNameSelect]![strTime]
where [frmNameSelect] is my subform, which is in a form named
frmPersonalInfo.
If frmNameSelect is opened on its own, the macro works like a charm. If
the
button is clicked in the subform (when frmPersonalInfo is opened), it acts
as
if it can't find the fields in frmNameSelect, pulling up a dialog box for
me
to enter the information.
:
the problem probably has to do with control references. what are the
macro
Condition(s), Action(s), and ActionArguments for each action?
I'm trying to write a macro that selects a certain record in Form A
depending
on the contents of fields in a subform. We'll say the subform is in
Form
B.
If I open the subform as its own seperate form and run the macro, it
functions properly. If I attempt to run the macro from the subform
(set
to
OnClick on a button), it acts like it can't find the contents of the
field.
Any suggestions?