Results 1 to 2 of 2
  1. #1
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286

    BUTTON keeps adding value to TABLE

    hello i have a button on my form with some textboxes bounded to a table. when i press a button i have some validations running, however even if the validations run through, it still adds the values that the user inputs in the textboxes into the table.

    please help, thanks!

    this is the code of the button, a picture is below. format of the text in the box is string. basically it doesnt matter what msgbox validation comes up, it still adds to the table its bounded to. i want to make it NOT add to the table if it the validation catches an error.

    Private Sub btngo_Click()
    Dim x As String
    x = DCount("*", "tblCustomerMaster", "CustomerID = '" & Me.frmtest.Form.Channel_ID & "'")

    If Me.LAN_ID <> "tshc" And Me.LAN_ID <> "rgv1" And Me.LAN_ID <> ("hxcm") And Me.LAN_ID <> ("j0hu") And Me.LAN_ID <> ("R2Wq") And Me.LAN_ID <> ("NSC4") And Me.LAN_ID <> ("ECD1") And Me.LAN_ID <> ("S2Bf") And Me.LAN_ID <> ("KKW2") Then


    MsgBox ("ERROR: You Don't Have Authorization!")
    ElseIf Me.frmtest.Form.Due_Date <= Date - 1 Then
    MsgBox ("ERROR: This is not a possible Due Date!")
    ElseIf x = 0 Then
    MsgBox ("ERROR: Invalid Channel ID")
    ElseIf Me.frmtest.Form.Due_Date <> "" And Me.frmtest.Form.Channel_ID <> "" Then
    DoCmd.GoToRecord , , acNewRec
    DoCmd****nMacro ("mcrHHFRequest_Tais")
    MsgBox ("You've Added A Record(s)!")
    DoCmd****nMacro ("mcrCloseEasyTrakEnter")
    DoCmd.OpenForm "frmeasytrak", acNormal
    Else

    MsgBox ("ERROR: Missing a Field")


    End If


    End Sub


    picture:
    http://i130.photobucket.com/albums/p...rmeasytrak.jpg

  2. #2
    metokushika is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    19
    as to what i understand about your code, the conditions you put will execute the code according to what the user will input.

    on your 1st, 2nd and 3rd condition of your code, it obviously checks an error but on your 4th condition, when there is no error at all, it will add a new record to your table.

    i understand that your "else condition" is similar to your 1st, 2nd and 3rd one. that when there's an error, it will not validate the data. but on your 4th condition, it will add data to your table.


    i suggest, how about if you try switching the 4th condition to the "else condition" and put the one in the else condition onto the 4th condition? or rather, delete the code on the else condition and place your 4th condition in the "else condition" TO TEST IF IT WILL WORK.


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

Similar Threads

  1. Replies: 4
    Last Post: 10-28-2011, 03:28 PM
  2. adding a sort control button
    By darklite in forum Forms
    Replies: 5
    Last Post: 01-24-2011, 03:32 PM
  3. Adding Pop-ups via Command Button
    By jlclark4 in forum Forms
    Replies: 1
    Last Post: 01-05-2011, 02:41 PM
  4. Replies: 3
    Last Post: 10-28-2010, 07:02 AM
  5. Adding Command Button To Form
    By uneek78 in forum Forms
    Replies: 7
    Last Post: 03-27-2009, 07: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