Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2009

    Unanswered: data search help

    Hi have following situation:
    i have a text box (in a form) where you enter in your customer ID. The accompanying command button opens up another form based on the ID of the customer that has been entered. Everything works well until here.

    However if the customer enters a non-valid ID which means an ID that is not in the Data base I want it to say "ID does not exist" before it opens up the form so zou can try again.

    here is the code I have for the comand button:

    Option Compare Database

    Private Sub Command9_Click()
    On Error GoTo Err_Command9_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Alternative Transportation Field Survey"

    stLinkCriteria = "[Dealer Code]=" & Me![Text2]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    MsgBox "Please enter the data into the yellow marked fields and save before you close the survey"

    Exit Sub

    MsgBox "Please enter Dealer ID"
    Resume Exit_Command9_Click

    End Sub

    thanks a lot!

  2. #2
    Join Date
    Feb 2009
    what happen when there is no matching record?
    if the form shows even if no matching record what is on the form?

    I believe you must find that record first before you open the form.
    so you can make an if else statement....
    Last edited by jerome.mercado26; 04-03-09 at 21:22.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts