I'm not sure if it would make a difference, but the txtPartNumber fields on
both forms are text fields with variant data, not numeric. I copied this
code and when I click the button to launch this command, I get a dialog box
asking me what txtPartNumber is.
* snipped *
If, however, [txtPartNumber] is a Text datatype field:
DoCmd.OpenForm "PartNumbers", , , "[txtPartNumber] = '" &
Me![txtPartNumber] & "'"
I've also simplified the rest of the where clause for you.
It's not the [txtPartNumber] on the forms but the [txtPartNumber]
field ** IN THE TABLE ** that is important here.
If it is Text Datatype, then the correct code and syntax is:
DoCmd.OpenForm "PartNumbers", , , "[txtPartNumber] = ' " &
Me![txtPartNumber] & " ' "
I've add a space between the single and double quotes above so that it
is clearer. Remove those spaces when you write the code.
If you are getting a prompt for [txtPartNumber] then Access doesn't
recognize it as a valid field. I have no idea what your form or table
field names are, so you'll need to work it out this way....
Here is a verbalized version of what the above code is supposed to do.
Change the field and table names to match your actual field and table
names.
Open the Form named "PartNumbers" where the field (in the table that
is the recordsource for the "PartNumbers" form ) named [txtPartNumber]
(which is a Text Datatype field) matches the control in this form
named [txtPartNumbers] .
If the value on the form of the [txtPartNumber] control is 1234 the
resultant Where clause will read:
"[txtPartNumber] = '1234'"
and that matching record will be displayed in the new form.