Results 1 to 6 of 6
  1. #1
    Secue is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    33

    Unhappy Data enter validation on a form

    I have a form to capture information, I have a button named "Save" on the form to sabe the information for the current record adn at the same time validate that all fields are not empty.



    I have the following code on the after click even of the button:
    for each field I have the following validation:


    If Nz(Me.Copies.Value, "") = "" Then
    Beep
    MsgBox "There is missing information - Copies" & Chr(13) & "Hay informacion ausente - Copies", vbExclamation, "MISSING INFORMATION"
    Copies.SetFocus




    at the end of each validation I have

    Else


    DoCmd.RunCommand acCmdSave


    And the corresponding End If needed, code was working fine and I even used this on other databases, but now I have problems with one especified field, I have a field where user can select a value from a list form another table. It was working fine when I used to select just one value, but I was requested to change to be able to select more tan one value, so when I set to multiselect on this field I have the following issues:

    When field is emty, it works fine, If I click on the button, I got the message that the field is empty. but when I select one value, or more tan one value, after I click on the button, I got a mistake message:
    Run-Time error '13':
    Type mismatch.

    What is worng on the code when field is set to acept more tan one value?

    Thank you.


  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Change to this and see if the issue goes away:
    If Len(Me.Copies & "") = 0 Then

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Multi-value fields are a pain in the ...

    The reason is they involve a 'hidden' table that actually stores the selected values. Review http://office.microsoft.com/en-us/ac...001233722.aspx

    Never run across anyone trying to validate a multi-value field. This field is required to have data? I guess you can handle the error. If you get the error, you know field has data.
    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.

  4. #4
    Secue is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    33
    RuralGuy:

    Thank you for your recomendation, I tried but I get the same mistake.

    June7:

    I will review the information on the link you provided.

    regarding your recomendation, I'm not expert on VBA, how can I catch the error witht he code that way as you said I will ensure the field is not emty and I can move to the next step.

    Thank you.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Here is an example of error handling code: http://allenbrowne.com/ser-23a.html

    Yours could be as simple as:

    Sub buttonname_Click()
    On Error GoTo ErrProc

    'validation code

    ExitProc:
    Exit Sub

    ErrorProc:
    If Err.Number = 13 Then
    Resume Next
    Else
    MsgBox Err.Number & " : " & Err.Description
    End If

    End Sub
    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.

  6. #6
    Secue is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    33
    Thank you, this solved my problema.

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

Similar Threads

  1. Replies: 4
    Last Post: 01-18-2013, 02:41 PM
  2. Replies: 1
    Last Post: 07-16-2012, 02:10 PM
  3. Can't enter or choose data in form
    By DMJ in forum Forms
    Replies: 3
    Last Post: 05-08-2012, 05:23 PM
  4. Replies: 4
    Last Post: 02-27-2012, 10:29 AM
  5. can't enter data in some form fields
    By ashiers in forum Forms
    Replies: 1
    Last Post: 09-18-2008, 12:37 PM

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