View Full Version : Dream, are you there? Help!!!


skarz
10-04-2001, 07:06 AM
Ok, I've created a form (frmSearch) to lookup contacts. I created a text control (txtSearchStringCompany) for users to enter a company name. I created a query (qryCompanyToDisplay) and set the critera of the company field to [Forms]![frmSearch]![txtSearchStringCompany]. I then created another form (frmCompanyToDisplay) and set (qryCompanyToDisplay) as the Record Source. Next I created a command button in the frmSearch and set it to open frmCompanyToDisplay. The event procedure for this button looks like this:

Private Sub cmdCompanyLookup_Click()
On Error GoTo Err_cmdCompanyLookup_Click

Dim stDocName As String

stDocName = "frmCompanyToDisplay"
DoCmd.OpenForm stDocName, acNormal, acEdit

Exit_cmdCompanyLookup_Click:
Exit Sub

Err_cmdCompanyLookup_Click:
MsgBox Err.Description
Resume Exit_cmdCompanyLookup_Click

End Sub

When I open the form, enter a company name and click the lookup button, a box prompts me to Enter Parameter Value. There is a text box with tblContacts.ID above it. Why won't it open frmCompanyToDisplay with the record for the company I entered in it? I obviously did something wrong but I have no idea what. Can you help me?

Sorry for the long post.

charityg
10-04-2001, 08:51 AM
Your kind of going about it the wrong way. For your form frmCompanytoDisplay, take off the criteria requirements. Then in the button on the frmSearch form, you will use a parameter in the openform command to go to the appropriate record(s).

Dim strLinkCriteria as string
Dim stDocName As String

stDocName = "frmCompanyToDisplay"

strLinkCriteria="CompanyName='" & me!txtSearchStringCompany & "'"

DoCmd.OpenForm stDocName, acNormal, acEdit,strLinkCriteria

I would actually use a combobox with a hidden primarykey to select the exact company and then set the linkcriteria for ID=cbobox, it's a more exact method.

HTH,
Charity


[This message has been edited by charityg (edited 10-04-2001).]