Results 1 to 7 of 7
  1. #1
    Anacronos is offline Novice
    Windows 8 Access 2013
    Join Date
    Jan 2016
    Posts
    24

    Preventing that de vba interface shows up. Plus avoid invalid data to be entered in a text box.


    I have a field that is generated by
    Me.Id = Format(Date, "YYYYMMDD") & "-" & Me.TxtId_dia
    So each day I can put one "1" and thereīs no problem. The deal is that when someone enters in the same day another "1" (I know itīs logical) a error message kicks in but the thing is I would like to write that text box by myself cuz that the default msgbox that shows up has a button that opens the interface of VBA so I donīt want my users to see that. I have no clue about how to do that thereīs no On error event on the text box.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It sounds like "Me.ID" ("ID" is a poor name) is the primary key of a table. If YOU enter a 1 for today and the value generated is "20160225-1" AND someone else later tries to enter a 1, you would have duplicate primary key values.
    Having duplicate primary key values is not allowed - so you get an error.
    If you don't want the debug error dialog box to be displayed, you need to add error handling to the routine or use custom autonumbers.

    Custom autonumbers (aka roll you own) would alleviate this problem.
    Something like http://baldyweb.com/CustomAutonumber.htm

  3. #3
    Anacronos is offline Novice
    Windows 8 Access 2013
    Join Date
    Jan 2016
    Posts
    24
    How can I add some error handling, since the event "On Error" does not apply to the text box?
    Iīm not worried about the custom autonumber, and thereīs another thing about it. Theyīre not always added sequentially.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    default msgbox that shows up has a button that opens the interface of VBA
    The error handler should be in the VBA code. Or maybe I'm misunderstanding your problem.

  5. #5
    Anacronos is offline Novice
    Windows 8 Access 2013
    Join Date
    Jan 2016
    Posts
    24
    No, I think you get it xD Iīm having trouble describing the problem xD. I want two things prevent that the user adds a number that has already been added that day and it will also prevent that that error message shows up.

  6. #6
    Anacronos is offline Novice
    Windows 8 Access 2013
    Join Date
    Jan 2016
    Posts
    24
    Fellow, I kind of solve it. I used the Dcount metod https://msdn.microsoft.com/en-us/lib...ffice.11).aspx
    So I counted the Id_dia already saved with the criteria being the date so It will only count those ones from the same day.
    Then with a If compared if it was more than >0. Thank you :3

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Glad you worked it out.

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

Similar Threads

  1. Replies: 6
    Last Post: 12-07-2015, 02:09 PM
  2. Replies: 9
    Last Post: 03-15-2015, 10:37 PM
  3. Replies: 7
    Last Post: 04-07-2014, 06:54 PM
  4. Replies: 1
    Last Post: 01-09-2013, 01:33 PM
  5. Replies: 12
    Last Post: 06-04-2012, 10:55 AM

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