Results 1 to 4 of 4
  1. #1
    Lianne is offline Novice
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Canada
    Posts
    2

    AutoFill works but error when field is empty

    I have made an Autofill which is working.
    Contacts & Tasks tables. In the Tasks details form Contact name is obtained from the Contacts tbl. Names and contact info is displayed.
    It works well when all of the contacts fields are filled and if a contact is selected in the tasks details form.

    Two problems.

    1. The form does not always need to use the Contact AutoFill. Error occurs when we try to save the new Task Details if Contact field is empty. [The form does not let us continue unless the autofill field is used.] Sometimes that field needs to be left blank.
    I am sure it is something like if null=.... what to say after null [I assume in the Event Tab /On Exit / ... / ? ]

    2. If the Contact fields I am bringing in [just to view] are 5 fields. If they are not filled in the primary [Contact] table we get an error. Sometimes we don't have info for all the fields.
    I believe the answer is similar to #1 If null.... but again I am sorry to say I don't know where to put the if statement and what to say afterwards.



    Thank you in advance for your help and thoughts.

    Lianne

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Need to review code. What do you mean by 'Autofill'?

    What are the exact error messages?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Lianne is offline Novice
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Canada
    Posts
    2
    Thanks for the quick reply. Sorry I should have included that - good questions.

    Everything works if a contact person is selected and if all the fields are filled in for that contact person [contacts tbl].

    When I try to save a new task without including a contact name the following error appears.
    "The Microsoft Accesss database engine cannot find a record in the table 'Contacts' with key matching field(s) 'ContactID'."

    Click image for larger version. 

Name:	No contact Name error  - no to required.png 
Views:	4 
Size:	25.4 KB 
ID:	15197

    I have made sure the last name and first name are not required fields in the Contact table.

    The following is the Event Procedure code In the Task Details form, I have the following code in the "On Change" for ContatName
    I believe I need to add code that says if ContactName is blank - continue anyway. Maybe add code in the "On Exit"? or in here?

    Private Sub cboContact_Change()
    Me.txtOrganization.Value = Me.cboContact.Column(3)
    Me.txtRole.Value = Me.cboContact.Column(4)
    Me.txtPhone.Value = Me.cboContact.Column(7)
    Me.txtCell.Value = Me.cboContact.Column(6)
    Me.txtEmailAddress.Value = Me.cboContact.Column(5)


    End Sub

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Sounds like Contacts and Tasks have a parent/child relationship that is enforced by the Relationships builder.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-21-2013, 10:40 AM
  2. Error on AddNew to an empty recordset
    By kowalski in forum Programming
    Replies: 7
    Last Post: 05-22-2013, 06:17 PM
  3. Replies: 1
    Last Post: 02-20-2012, 01:02 PM
  4. Form works, Subform gets error
    By jlclark4 in forum Forms
    Replies: 9
    Last Post: 01-03-2011, 09:24 AM
  5. Autofill field based on autonumber field
    By frevilla in forum Forms
    Replies: 1
    Last Post: 09-11-2009, 02:50 AM

Tags for this Thread

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