OpenForms Action

M

MAG

I have a small program written to open a form by finding a
specific part number. I have the enter the number in an
input box then have it open to that record. It seems to
work ok except another box opens asking for parameter
value, which is the Part. I would like to get rid of one
of them but dont know what is causeing the second. If i
dont use the InputBox then it just opens up a blank
record. Here is a piece of the code.

Part = InputBox(Message, Title)

DoCmd.OpenForm "Products", , , " [P/N] = Part "

Any suggestions would be appreciated.
Thanks
MAG
 
A

Albert D. Kallal

That string you pass MUST be a correctly formatted "where" clause. That
string must look like if you jus typed it in.

As you have that string, you are looking for a [p/n] = part.

[p/n] = zoo

The above would look for a p/n of zoo. Also, while you are at it, I would
avoid using spaces, "/", or other weird character in your fields. Perhaps
you are trying to dive the value of p by n p / n.


anyway, try:
Part = InputBox(Message, Title)

DoCmd.OpenForm "Products", , , "[P/N] = " & Part

Also, if part is a string field in the table, and not an actaull number
type, then you have to use:
DoCmd.OpenForm "Products", , , "[P/N] = '" & Part & "'"

So, just like in sql, you have to surround the text with single quotes, the
sample applies for the "where" clause. (but only for numbers do you need the
quotes).
 

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