Results 1 to 4 of 4
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Ending my if statements

    I have 2 if statements. The first is to add a new record. It will give the message I put into it, but won't go to a new record. Here's the code:

    Private Sub btnAdd_Click()
    If IsNull(cboEquipTypeID) And IsNull(EquipID) Then
    MsgBox "You need to choose a type"
    ElseIf (cboSerialNo = 0) And IsNull(QuantityOut) Then
    MsgBox "Enter a quantity"
    ElseIf (cboSerialNo) Then
    DoCmd.GoToRecord , "", acNewRec
    End If

    End Sub

    The second code also gives the message I put into it, but won't close the form. Here's the code:

    Private Sub btnSave_Click()
    If IsNull(cboEquipTypeID) And IsNull(EquipID) Then
    MsgBox "You need to choose a type"
    ElseIf (cboSerialNo = 0) And IsNull(QuantityOut) Then
    MsgBox "Enter a quantity"
    ElseIf (cboSerialNo) Then


    DoCmd.OpenQuery "qryIssueEquipUpdate"
    Me.IssuedByID.Value = Forms!frmMainMenu.txtUserID
    DoCmd.Close
    End If

    End Sub

    I'm not sure what I did wrong.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The last ElseIf should probably just be Else, with no test.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Perfect. Guess I was overthinking it. Thanks.

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Log In Ending
    By GCLIFTON in forum Access
    Replies: 10
    Last Post: 06-02-2016, 11:12 AM
  2. Starting and Ending Dates in Query
    By NewbyForAccess in forum Queries
    Replies: 9
    Last Post: 10-08-2015, 08:04 PM
  3. Alert for Position ending in 6 months
    By enquiries in forum Access
    Replies: 2
    Last Post: 04-22-2014, 03:09 PM
  4. Image as never ending wallpaper
    By 95DSM in forum Database Design
    Replies: 1
    Last Post: 07-30-2010, 10:02 AM
  5. Viewing ending zeros in decimal
    By duecesup in forum Reports
    Replies: 0
    Last Post: 12-11-2008, 02:45 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