DoCmd.OpenForm

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having troubles with my DoCmd.OpenForm code in the WhereCondition. I am
getting a Debug Error saying it can't find the name of my form in the where
condition, however I have checked and triple checked and it is spelled right.
Here is my code maybe I am just typing it out slightly wrong. Can anyone
see what is wrong with this code or why it is saying the form doesn't exist
when it does.

DoCmd.OpenForm "frm_DrawingNumSearch", _
acNormal, , Me.lstMachineNumbers.Column(0) _
= [Forms]![frm_DrawingNumSearch]![lstDrawingNumbers.Column(3)]

is it possibly not working because I am opening the form first and then
trying to reference it? I don't know but if some one does please help.

Thanks in advance.
 
First, Me refers to the form or report on which the code is running. So, it
appears that you are trying to set a value of a control on the calling form
to a value on the form being opened (left side of = is the receiver). The
WHERE condition is used to filter the values in the form being opened so
that you will only see the value(s) you listed in the WHERE.

To set the value of the item on the calling form, do this in a subsequent
line of code following the opening of the second form.

If you do intend to have a WHERE clause, the clause should refer to a field
in the form's recordset. Here is an example of a DoCmd.OpenForm statement
with a WHERE clause from the Help file.

DoCmd.OpenForm "Employees", , ,"LastName = 'King'"

Notice that this will limit the recordset of the form being opened to those
records where the LastName field is King.
 
Back
Top