Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a Where Condition To Open A Form

Status
Not open for further replies.

EllieFant

MIS
May 15, 2001
513
US
I have been creating macros and converting them to VBA to learn how to use code and not a macro for everything. I am having troubles getting the following situation to work.

User clicks on a button on my menu form that opens up a search form

Form Name: SearchFindingNumber
Unbound Text Box: SearchFindingNumber
OK Button Name: SearchFind

The user will enter the finding number into the unbound box (Number format is #-#).

When they click on the SearchFind button I want my InspectFindings form to open.

Form Name: InspectFindings
Field to match: FindingNum (which is an unbound box with the control source of: =[InspNumber] & "-" & [FindingNumber])

This is the command I have tried:

DoCmd.OpenForm "InspectFindings", acNormal, "", "[Forms]![InspectFindings]![FindingNum]=[Forms]![SearchFindingNumber]![SearchFindingNumber]", acEdit, acNormal

It doesn't open the finding - it opens a blank form like maybe it isn't finding that finding. I am sure my mistake is a simple thing to fix, but being somewhat new at VBA and the proper way of coding things, I am not sure what I have done wrong.

Thanks!

Ellie
**Using Access 97 at work**
**Using Access 2000 at home**

elliefant@qwest.net
 
What about....

Docmd.OpenForm "InspectFindings",,,"FindingNum = '" & me.txtSearchFindingNumber & "'"

I think I have the right # of commas... you don't need to enter quotes on arguments you don't need. Just watch the apostrophes, single & double quotes on your criteria...

You would enter this on the 'On click" event for your command button...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top