By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,030 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,030 IT Pros & Developers. It's quick & easy.

Combo box Search Problem

P: 67
Hello all

I am trying to create a search form. I have a table called tblContact which has the field for postcodes in it. I have another table called tblSales which i have created a query to link the tblContacts to. On the frmSales the Postcode is a combo box. I am using the code below to search for the postcodes. I can't get it to find a postcode via the combo box. Sorry if i am not being very clear as my coding is very basic. Please help, thanks.


Private Sub btnSearch_Click()
Dim strSearch As String

If IsNull(Me![PostcodeSearch]) Or (Me![PostcodeSearch]) = "" Then
MsgBox "You Must Enter A Postcode!", vbOKOnly, "Invalid Search!"
Me![PostcodeSearch].SetFocus
Exit Sub
End If

DoCmd.ShowAllRecords
DoCmd.GoToControl ("Postcode")
DoCmd.FindRecord Me!PostcodeSearch

Postcode.SetFocus
strPostcodeRef = Postcode.Text
PostcodeSearch.SetFocus
strSearch = PostcodeSearch.Text

If strPostcodeRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Match Found!"
Postcode.SetFocus
PostcodeSearch = ""

Else
MsgBox "No Match For: " & strSearch & " - Please Try Again.", _
, "No Match Found!"
PostcodeSearch.SetFocus
End If
End Sub
Oct 2 '08 #1
Share this Question
Share on Google+
1 Reply


P: 67
Hi again

The problem isn't the combo box as when i link the tblContact direct to the control source it works fine. so its linking through a query where i am having the trouble. Please advise. Regards
Oct 2 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.