Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    43

    Unanswered: Simple database help

    I do not know what Im doing..

    I have a form with an unbound box for user input.
    a button on the form with the following code..
    How do I add a statement that handles the case of no match? Currently when you enter a name or number with no match it gives me a big blank form!
    Thanks

    Private Sub Command3_Click()
    On Error GoTo Err_Command3_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FORM"

    stLinkCriteria = "[Expr1]LIKE " & "'" & Me![FINDEMPNO] & "*'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Exit_Command3_Click:
    Exit Sub

    Err_Command3_Click:
    MsgBox Err.Description
    Resume Exit_Command3_Click

    End Sub

  2. #2
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    25

    Re: Simple database help

    You could use DCount to check if there are any matching records in the table. ie if dcount with the given criteria = 0 then pop up a message box saying try again - Access help gives you the syntax

  3. #3
    Join Date
    Mar 2004
    Posts
    43
    any ideas on why I get a blank form instead of a blank record??

    Thanks for the help

  4. #4
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    25
    It could be because the form's Allow Additions property is set to no.

Posting Permissions

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