Search Form

C

Colin

Hi,

I have a form with a combo box. It lists the contact
names, from another form called customers. I have tried
to create a button so that when I select the contact name
from the drop down box and click the button, it will
search for the record relating to this contact name from
the customer records.

Does anyone know how?

I have tried making a command button to open the form but
when I use it it just opens a blank version, not the one
selected in the combo box. Here is the script,

____________________
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Customers"

stLinkCriteria = "[ContactName]=" & "'" & Me![Combo0]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub
__________________________

Can anyone see what is worng with this and how to fix it?

I would very much appreciate it,

Regards

Colin
 
P

Pavel Romashkin

I think that Combo1 does not return a name you need. Perhaps it returns
the ID of the contact, not the name.
I suggest setting a breakpoint at the line

DoCmd.OpenForm stDocName, , , stLinkCriteria

and printing out stLinkCriteria to see what is being sent to the form to
filter it.
Pavel
 

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