Results 1 to 3 of 3
  1. #1
    psych is offline Novice
    Windows 7 Access 2007
    Join Date
    Mar 2010
    Posts
    2

    Using IIF to compare two fields data

    Hi All,



    New to Access.
    I have a form that I like to do some field compare.
    Subj_num to c-subj_num
    And also I have a filed called Cal.

    I like to compare Subj_num to c-subj_num, and if their values are not equal then have Number 1 inserted into "cal" field.
    Code:
     
    if Subj_num not equal c-subj_num
    then cal = 1
    Thanks for any help.


    A

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    assuming you want to do this in the form, during user data entry - then in the AfterUpdate event of either box that will be completed last you would put:

    if me.Subj_num <> me.c-subj_num then
    me.cal = 1
    end if

    I trust all those fields are defined as numbers in their underlying table field property...

  3. #3
    psych is offline Novice
    Windows 7 Access 2007
    Join Date
    Mar 2010
    Posts
    2
    Yes all the fields are number
    In design mode:
    Selected “Subj_num”
    In Prosperity Sheet: selected “Event” tab
    Selected [Event Procedure] from “After Update”
    And I have the following code in there
    Code:
    Private Sub subj_num_AfterUpdate()
    If PIH.subj_num <> PHI.C_subj_num Then PHI.cal = 1
    End If
    End Sub
    Then I go to the form and switch to “Form View”
    Enter “1234” in “Subj_num” , then Enter “333333” in “C_Subj_num” field, then clicking on “cal” filed. Nothing happened.
    There is not number “1” in cal field.

    Am I doing anything wrong in here?

    Please let me know.

    A

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

Similar Threads

  1. Fields - No Data
    By tempowls21 in forum Access
    Replies: 1
    Last Post: 06-19-2013, 06:12 AM
  2. Compare msaccess data
    By dref in forum Queries
    Replies: 10
    Last Post: 05-14-2010, 05:35 AM
  3. Compare two fields!
    By finditsol in forum Forms
    Replies: 1
    Last Post: 02-11-2010, 01:43 PM
  4. Replies: 1
    Last Post: 02-03-2010, 09:17 PM
  5. Replies: 0
    Last Post: 08-01-2009, 12:43 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