Results 1 to 2 of 2
  1. #1
    bob500000 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2011
    Posts
    15

    How to retrieve and display a record based on the value in a combo box.

    Hi Guys,

    I am trying to select a record based on the value of a combo box, I can't use the wizard as I have code that currently lets you select the value and registers for later, I want to then use that value to open a record.

    Below is sample code for the selection and combo box, the box is called results just to clarify.

    I know this code works but I now what it to open a record when I select the value, any help would be great.

    Private Sub Results_Click()
    Dim x As Integer


    Dim result As String
    Dim strSQL As String

    For x = 0 To Results.ListCount - 3
    If Results.Value > 0 Then
    result = Results.Value
    strSQL = "SELECT [Customer Name] FROM Customer WHERE [Customer ID] LIKE '*" & str & "*' OR[Customer Name] LIKE '*" & str & "*' OR[Customer Address] LIKE '*" & str & "*' OR[Customer City] LIKE '*" & str & "*' OR[Customer Post Code] LIKE '*" & str & "*'OR[Customer Region] LIKE '*" & str & "*' OR[Customer County] LIKE '*" & str & "*'OR[Customer Country] LIKE '*" & str & "*' OR[Customer Telephone No] LIKE '*" & str & "*'OR[Customer Date of Birth] LIKE '*" & str & "*' OR[Customer Type] LIKE '*" & str & "*'OR[Payment Method] LIKE '*" & str & "*'"
    DoCmd.RunSQL (strSQL)

    End If

    Next
    End Sub

  2. #2
    bob500000 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2011
    Posts
    15
    I have solved this now, will close

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Combo Boxes always display first record of table
    By LilMissAttack in forum Forms
    Replies: 4
    Last Post: 08-12-2011, 11:36 AM
  2. Replies: 5
    Last Post: 03-11-2011, 11:28 AM
  3. Retrieve group records based on max value
    By wireless in forum Access
    Replies: 7
    Last Post: 02-03-2011, 03:30 PM
  4. Replies: 0
    Last Post: 06-03-2009, 10:25 PM
  5. Adding a record based on combo
    By cjamps in forum Forms
    Replies: 1
    Last Post: 02-24-2009, 12:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums