Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2009
    Posts
    37

    Unanswered: Adding new records to a table via a form

    Hi I am trying to add some new records to a table via an input form. I do however want a message to pop up if the record does not already exit in the table and then not to add it.

    I have this until now:

    If IsNull(DLookup([(SE)_tbl_List_Strategies].[strategy], [(SE)_tbl_List_Strategies], "x")) Then
    MsgBox "this strategy does not exist"
    Else

    it comes up with the follwoing error message:
    runtime error 2465
    cannot find the field "/" referred to in your expression.

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Quote Originally Posted by Tiggerandpoo
    Hi I am trying to add some new records to a table via an input form. I do however want a message to pop up if the record does not already exit in the table and then not to add it.

    I have this until now:

    If IsNull(DLookup([(SE)_tbl_List_Strategies].[strategy], [(SE)_tbl_List_Strategies], "x")) Then
    MsgBox "this strategy does not exist"
    Else

    it comes up with the follwoing error message:
    runtime error 2465
    cannot find the field "/" referred to in your expression.
    Hi

    There are so many issues with you code I don't know where to begin.

    However, the Domain Functions (DLookup,DCount etc) require strings are there arguments, and, on the basis that you are checking for a unique record, I would use DCount() because then there is no 'Null" issue (ie it allways returns an integer, zero if not found).

    Also, do you realy have brackets in you table name !!??
    On the basis that you do, and the Unique field (PK?) is the Strategy field and x is a variable or control on your form, then try something like this

    DCount("strategy", "(SE)_tbl_List_Strategies", "strategy = '" & x & "'")

    I have assumed strategy is a Text field, but if it is a number then try this

    DCount("strategy", "(SE)_tbl_List_Strategies", "strategy = " & x)

    I don't kow if that helps but it should remove some of the potential problems !


    MTB

  3. #3
    Join Date
    Mar 2009
    Posts
    37
    THANK YOU SO MUCH!!!! Consider yourself hugged! It is working!

Posting Permissions

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